/* Generated by Cython 0.23.3 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": []
    }
}
END: Cython Metadata */

#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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_23_3"
#include <stddef.h>
#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 !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
#define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#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+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#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)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 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_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #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_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#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_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#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
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  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
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
typedef struct {
    unaryfunc am_await;
    unaryfunc am_aiter;
    unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None)

#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

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#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

#define __PYX_HAVE__plastid__genomics__roitools
#define __PYX_HAVE_API__plastid__genomics__roitools
#include "string.h"
#include "stdio.h"
#include "pythread.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "pystate.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#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
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (_MSC_VER) && defined (_M_X64)
    #define __Pyx_sst_abs(value) _abs64(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(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);
#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))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
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[] = {
  "plastid/genomics/roitools.pyx",
  "plastid/genomics/roitools.pxd",
  "array.pxd",
  "__init__.pxd",
  "stringsource",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
};
struct __pyx_memoryview_obj;
typedef struct {
  struct __pyx_memoryview_obj *memview;
  char *data;
  Py_ssize_t shape[8];
  Py_ssize_t strides[8];
  Py_ssize_t suboffsets[8];
} __Pyx_memviewslice;

#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
  const char* name;
  struct __Pyx_StructField_* fields;
  size_t size;
  size_t arraysize[8];
  int ndim;
  char typegroup;
  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;

#include <pythread.h>
#ifndef CYTHON_ATOMICS
    #define CYTHON_ATOMICS 1
#endif
#define __pyx_atomic_int_type int
#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
                    (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
                    !defined(__i386__)
    #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
    #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Using GNU atomics"
    #endif
#elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
    #include <Windows.h>
    #undef __pyx_atomic_int_type
    #define __pyx_atomic_int_type LONG
    #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
    #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
    #ifdef __PYX_DEBUG_ATOMICS
        #pragma message ("Using MSVC atomics")
    #endif
#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
    #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
    #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Using Intel atomics"
    #endif
#else
    #undef CYTHON_ATOMICS
    #define CYTHON_ATOMICS 0
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Not using atomics"
    #endif
#endif
typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
#if CYTHON_ATOMICS
    #define __pyx_add_acquisition_count(memview)\
             __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
    #define __pyx_sub_acquisition_count(memview)\
            __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
#else
    #define __pyx_add_acquisition_count(memview)\
            __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
    #define __pyx_sub_acquisition_count(memview)\
            __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
#endif


/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":725
 * # 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":726
 * 
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":727
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":728
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":732
 * #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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":733
 * 
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":734
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":735
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":739
 * #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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":740
 * 
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":749
 * # 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":750
 * # 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":751
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":753
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":754
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":755
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":757
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":758
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":760
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":761
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":762
 * 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;

/* "plastid/genomics/roitools.pyx":132
 * LONG   = numpy.long
 * 
 * ctypedef numpy.int_t    INT_t             # <<<<<<<<<<<<<<
 * ctypedef numpy.float_t  FLOAT_t
 * ctypedef numpy.double_t DOUBLE_t
 */
typedef __pyx_t_5numpy_int_t __pyx_t_7plastid_8genomics_8roitools_INT_t;

/* "plastid/genomics/roitools.pyx":133
 * 
 * ctypedef numpy.int_t    INT_t
 * ctypedef numpy.float_t  FLOAT_t             # <<<<<<<<<<<<<<
 * ctypedef numpy.double_t DOUBLE_t
 * ctypedef numpy.long_t   LONG_t
 */
typedef __pyx_t_5numpy_float_t __pyx_t_7plastid_8genomics_8roitools_FLOAT_t;

/* "plastid/genomics/roitools.pyx":134
 * ctypedef numpy.int_t    INT_t
 * ctypedef numpy.float_t  FLOAT_t
 * ctypedef numpy.double_t DOUBLE_t             # <<<<<<<<<<<<<<
 * ctypedef numpy.long_t   LONG_t
 * 
 */
typedef __pyx_t_5numpy_double_t __pyx_t_7plastid_8genomics_8roitools_DOUBLE_t;

/* "plastid/genomics/roitools.pyx":135
 * ctypedef numpy.float_t  FLOAT_t
 * ctypedef numpy.double_t DOUBLE_t
 * ctypedef numpy.long_t   LONG_t             # <<<<<<<<<<<<<<
 * 
 * cdef class SegmentChain
 */
typedef __pyx_t_5numpy_long_t __pyx_t_7plastid_8genomics_8roitools_LONG_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 ---*/
#ifndef _ARRAYARRAY_H
struct arrayobject;
typedef struct arrayobject arrayobject;
#endif
struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment;
struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain;
struct __pyx_obj_7plastid_8genomics_8roitools_Transcript;
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed;
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr;
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr;
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr;
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr;
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl;
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr;
struct __pyx_array_obj;
struct __pyx_MemviewEnum_obj;
struct __pyx_memoryview_obj;
struct __pyx_memoryviewslice_obj;

/* "plastid/genomics/c_common.pxd":1
 * cdef enum Strand:             # <<<<<<<<<<<<<<
 *     undef_strand   = 0
 *     forward_strand = 1   # can use bitwise operations to detect overlap
 */
enum __pyx_t_7plastid_8genomics_8c_common_Strand {
  __pyx_e_7plastid_8genomics_8c_common_undef_strand = 0,
  __pyx_e_7plastid_8genomics_8c_common_forward_strand = 1,
  __pyx_e_7plastid_8genomics_8c_common_reverse_strand = 2,
  __pyx_e_7plastid_8genomics_8c_common_unstranded = 3
};

/* "plastid/genomics/c_common.pxd":7
 *     unstranded     = 3
 * 
 * cdef enum ExBool:             # <<<<<<<<<<<<<<
 *     bool_exception = -1
 *     false     = 0
 */
enum __pyx_t_7plastid_8genomics_8c_common_ExBool {
  __pyx_e_7plastid_8genomics_8c_common_bool_exception = -1L,
  __pyx_e_7plastid_8genomics_8c_common_false = 0,
  __pyx_e_7plastid_8genomics_8c_common_true = 1
};

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":764
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":765
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":766
 * 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;

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":768
 * ctypedef npy_clongdouble clongdouble_t
 * 
 * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 */
typedef npy_cdouble __pyx_t_5numpy_complex_t;

/* "plastid/genomics/roitools.pxd":16
 * 
 * 
 * cdef class GenomicSegment(object):             # <<<<<<<<<<<<<<
 *     cdef str chrom
 *     cdef long start
 */
struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment {
  PyObject_HEAD
  struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *__pyx_vtab;
  PyObject *chrom;
  long start;
  long end;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand c_strand;
};


/* "plastid/genomics/roitools.pxd":26
 *     cpdef str as_igv_str(self)
 * 
 * cdef class SegmentChain(object):             # <<<<<<<<<<<<<<
 *     cdef:
 *         list _segments, _mask_segments
 */
struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain {
  PyObject_HEAD
  struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *__pyx_vtab;
  PyObject *_segments;
  PyObject *_mask_segments;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *spanning_segment;
  long length;
  long masked_length;
  arrayobject *_position_hash;
  arrayobject *_position_mask;
  PyObject *attr;
  PyObject *_inverse_hash;
};


/* "plastid/genomics/roitools.pxd":66
 * 
 * 
 * cdef class Transcript(SegmentChain):             # <<<<<<<<<<<<<<
 *     cdef:
 *         object cds_genome_start, cds_genome_end, cds_start, cds_end
 */
struct __pyx_obj_7plastid_8genomics_8roitools_Transcript {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain __pyx_base;
  PyObject *cds_genome_start;
  PyObject *cds_genome_end;
  PyObject *cds_start;
  PyObject *cds_end;
};


/* "plastid/genomics/roitools.pyx":2222
 * 
 *     # TODO: optimize
 *     def as_bed(self, thickstart=None, thickend=None, as_int=True, color=None, extra_columns=None):             # <<<<<<<<<<<<<<
 *         """Format |SegmentChain| as a string of BED12[+X] output.
 * 
 */
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed {
  PyObject_HEAD
  PyObject *__pyx_v_color;
};


/* "plastid/genomics/roitools.pyx":2312
 *                 else:
 *                     # is a tuple or sequence
 *                     if all(isinstance(X,float) for X in color) and \             # <<<<<<<<<<<<<<
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):
 */
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *__pyx_outer_scope;
  PyObject *__pyx_v_X;
};


/* "plastid/genomics/roitools.pyx":2313
 *                     # is a tuple or sequence
 *                     if all(isinstance(X,float) for X in color) and \
 *                        all(X < 1 for X in color) and \             # <<<<<<<<<<<<<<
 *                        all(X > 0 for X in color):
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)
 */
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr {
  PyObject_HEAD
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *__pyx_outer_scope;
  PyObject *__pyx_v_X;
};


/* "plastid/genomics/roitools.pyx":2314
 *                     if all(isinstance(X,float) for X in color) and \
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):             # <<<<<<<<<<<<<<
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)
 *                     else:
 */
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr {
  PyObject_HEAD
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *__pyx_outer_scope;
  PyObject *__pyx_v_X;
};


/* "plastid/genomics/roitools.pyx":2315
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)             # <<<<<<<<<<<<<<
 *                     else:
 *                        color = "%s,%s,%s" % tuple(color)
 */
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr {
  PyObject_HEAD
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *__pyx_outer_scope;
  PyObject *__pyx_v_X;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "plastid/genomics/roitools.pyx":2350
 *             return ""
 * 
 *     def as_psl(self):             # <<<<<<<<<<<<<<
 *         """Formats |SegmentChain| as `PSL`_ (blat) output.
 * 
 */
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl {
  PyObject_HEAD
  PyObject *__pyx_v_ltmp;
};


/* "plastid/genomics/roitools.pyx":2434
 *             ltmp.append(q_starts)
 *             ltmp.append(t_starts)
 *             return "\t".join(str(X) for X in ltmp) + "\n"             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise AttributeError("SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end")
 */
struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr {
  PyObject_HEAD
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *__pyx_outer_scope;
  PyObject *__pyx_v_X;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};


/* "View.MemoryView":101
 * 
 * @cname("__pyx_array")
 * cdef class array:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_array_obj {
  PyObject_HEAD
  char *data;
  Py_ssize_t len;
  char *format;
  int ndim;
  Py_ssize_t *_shape;
  Py_ssize_t *_strides;
  Py_ssize_t itemsize;
  PyObject *mode;
  PyObject *_format;
  void (*callback_free_data)(void *);
  int free_data;
  int dtype_is_object;
};


/* "View.MemoryView":271
 * 
 * @cname('__pyx_MemviewEnum')
 * cdef class Enum(object):             # <<<<<<<<<<<<<<
 *     cdef object name
 *     def __init__(self, name):
 */
struct __pyx_MemviewEnum_obj {
  PyObject_HEAD
  PyObject *name;
};


/* "View.MemoryView":304
 * 
 * @cname('__pyx_memoryview')
 * cdef class memoryview(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef object obj
 */
struct __pyx_memoryview_obj {
  PyObject_HEAD
  struct __pyx_vtabstruct_memoryview *__pyx_vtab;
  PyObject *obj;
  PyObject *_size;
  PyObject *_array_interface;
  PyThread_type_lock lock;
  __pyx_atomic_int acquisition_count[2];
  __pyx_atomic_int *acquisition_count_aligned_p;
  Py_buffer view;
  int flags;
  int dtype_is_object;
  __Pyx_TypeInfo *typeinfo;
};


/* "View.MemoryView":923
 * 
 * @cname('__pyx_memoryviewslice')
 * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
 *     "Internal class for passing memoryview slices to Python"
 * 
 */
struct __pyx_memoryviewslice_obj {
  struct __pyx_memoryview_obj __pyx_base;
  __Pyx_memviewslice from_slice;
  PyObject *from_object;
  PyObject *(*to_object_func)(char *);
  int (*to_dtype_func)(char *, PyObject *);
};



/* "plastid/genomics/roitools.pyx":585
 * #==============================================================================
 * 
 * cdef class GenomicSegment:             # <<<<<<<<<<<<<<
 *     """A continuous segment of the genome, defined by a chromosome name,
 *     a start coordinate, and end coordinate, and a strand. Building block
 */

struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment {
  int (*contains)(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, int __pyx_skip_dispatch);
  int (*overlaps)(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, int __pyx_skip_dispatch);
  int (*_cmp_helper)(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, int, int __pyx_skip_dispatch);
  PyObject *(*as_igv_str)(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *__pyx_vtabptr_7plastid_8genomics_8roitools_GenomicSegment;


/* "plastid/genomics/roitools.pyx":899
 *             return self.c_strand
 * 
 * cdef class SegmentChain(object):             # <<<<<<<<<<<<<<
 *     """Base class for genomic features. |SegmentChains| can contain zero or more
 *     |GenomicSegments|, and therefore can model discontinuous, features -- such
 */

struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain {
  int (*c_add_segments)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, PyObject *);
  int (*_set_segments)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, PyObject *);
  int (*_set_masks)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, PyObject *);
  void (*c_reset_masks)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  PyObject *(*_get_inverse_hash)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  PyObject *(*c_shares_segments_with)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*c_covers)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*c_unstranded_overlaps)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*c_overlaps)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*c_antisense_overlaps)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*c_contains)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  PyObject *(*c_get_position_list)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  PyObject *(*c_get_position_set)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *);
  PyArrayObject *(*c_get_position_array)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, int);
  PyObject *(*get_masked_position_set)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, int __pyx_skip_dispatch);
  long (*c_get_genomic_coordinate)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, long, int);
  long (*c_get_segmentchain_coordinate)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, long, int);
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *(*c_get_subchain)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, long, long, int);
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *(*get_antisense)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *__pyx_vtabptr_7plastid_8genomics_8roitools_SegmentChain;


/* "plastid/genomics/roitools.pyx":3085
 * 
 * 
 * cdef class Transcript(SegmentChain):             # <<<<<<<<<<<<<<
 *     """Subclass of |SegmentChain| specifically for transcripts.
 *     In addition to coordinate-conversion, count fetching, sequence fetching,
 */

struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript {
  struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain __pyx_base;
  int (*_update_cds)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *);
  int (*_update_from_cds_start)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *);
  int (*_update_from_cds_end)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *);
  int (*_update_from_cds_genome_start)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *);
  int (*_update_from_cds_genome_end)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *);
};
static struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *__pyx_vtabptr_7plastid_8genomics_8roitools_Transcript;


/* "View.MemoryView":304
 * 
 * @cname('__pyx_memoryview')
 * cdef class memoryview(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef object obj
 */

struct __pyx_vtabstruct_memoryview {
  char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
  PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
  PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
  PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
  PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
};
static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;


/* "View.MemoryView":923
 * 
 * @cname('__pyx_memoryviewslice')
 * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
 *     "Internal class for passing memoryview slices to Python"
 * 
 */

struct __pyx_vtabstruct__memoryviewslice {
  struct __pyx_vtabstruct_memoryview __pyx_base;
};
static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;

/* --- Runtime support code (head) --- */
#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);
  #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
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#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)

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name);

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

static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod0(cfunc, self)\
    ((likely((cfunc)->func)) ?\
        (likely((cfunc)->flag == METH_NOARGS) ?  (*((cfunc)->func))(self, NULL) :\
         (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ?  ((*(PyCFunctionWithKeywords)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
             ((cfunc)->flag == METH_VARARGS ?  (*((cfunc)->func))(self, __pyx_empty_tuple) : __Pyx__CallUnboundCMethod0(cfunc, self)))) :\
        __Pyx__CallUnboundCMethod0(cfunc, self))
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

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);

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

#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) & likely(len > (L->allocated >> 1))) {
        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

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyString_Join __Pyx_PyBytes_Join
#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
#else
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION < 3
    #define __Pyx_PyBytes_Join _PyString_Join
    #else
    #define __Pyx_PyBytes_Join _PyBytes_Join
    #endif
#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
#endif

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

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

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);

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

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

#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

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

#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

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

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

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_ListComp_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_ListComp_Append(L,x) PyList_Append(L,x)
#endif

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

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

static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject* none = _PyList_Extend((PyListObject*)L, v);
    if (unlikely(!none))
        return -1;
    Py_DECREF(none);
    return 0;
#else
    return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
#endif
}

static void __Pyx_RaiseBufferIndexError(int axis);

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_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
#define __Pyx_MEMVIEW_DIRECT   1
#define __Pyx_MEMVIEW_PTR      2
#define __Pyx_MEMVIEW_FULL     4
#define __Pyx_MEMVIEW_CONTIG   8
#define __Pyx_MEMVIEW_STRIDED  16
#define __Pyx_MEMVIEW_FOLLOW   32
#define __Pyx_IS_C_CONTIG 1
#define __Pyx_IS_F_CONTIG 2
static int __Pyx_init_memviewslice(
                struct __pyx_memoryview_obj *memview,
                int ndim,
                __Pyx_memviewslice *memviewslice,
                int memview_is_new_reference);
static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
    __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
    __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);

#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
#else
#define __Pyx_PyList_GetSlice(seq, start, stop)   PySequence_GetSlice(seq, start, stop)
#define __Pyx_PyTuple_GetSlice(seq, start, stop)  PySequence_GetSlice(seq, start, stop)
#endif

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

static void __Pyx_RaiseBufferFallbackError(void);

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

static CYTHON_INLINE long __Pyx_mod_long(long, long);

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

static double __Pyx__PyObject_AsDouble(PyObject* obj);
#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

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

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

static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)\
    __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)
static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
        PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d);

static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);

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 int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping);

static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);

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

static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static PyObject *get_memview(PyObject *__pyx_v_self); /*proto*/
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

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

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self); /*proto*/
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

static CYTHON_INLINE long __Pyx_div_long(long, long);

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

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);

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);

#ifndef _ARRAYARRAY_H
#define _ARRAYARRAY_H
typedef struct arraydescr {
    int typecode;
    int itemsize;
    PyObject * (*getitem)(struct arrayobject *, Py_ssize_t);
    int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *);
#if PY_MAJOR_VERSION >= 3
    char *formats;
#endif
} arraydescr;
struct arrayobject {
    PyObject_HEAD
    Py_ssize_t ob_size;
    union {
        char *ob_item;
        float *as_floats;
        double *as_doubles;
        int *as_ints;
        unsigned int *as_uints;
        unsigned char *as_uchars;
        signed char *as_schars;
        char *as_chars;
        unsigned long *as_ulongs;
        long *as_longs;
        short *as_shorts;
        unsigned short *as_ushorts;
        Py_UNICODE *as_pyunicodes;
        void *as_voidptr;
    } data;
    Py_ssize_t allocated;
    struct arraydescr *ob_descr;
    PyObject *weakreflist;
#if PY_MAJOR_VERSION >= 3
        int ob_exports;
#endif
};
#ifndef NO_NEWARRAY_INLINE
static CYTHON_INLINE PyObject * newarrayobject(PyTypeObject *type, Py_ssize_t size,
    struct arraydescr *descr) {
    arrayobject *op;
    size_t nbytes;
    if (size < 0) {
        PyErr_BadInternalCall();
        return NULL;
    }
    nbytes = size * descr->itemsize;
    if (nbytes / descr->itemsize != (size_t)size) {
        return PyErr_NoMemory();
    }
    op = (arrayobject *) type->tp_alloc(type, 0);
    if (op == NULL) {
        return NULL;
    }
    op->ob_descr = descr;
    op->allocated = size;
    op->weakreflist = NULL;
    op->ob_size = size;
    if (size <= 0) {
        op->data.ob_item = NULL;
    }
    else {
        op->data.ob_item = PyMem_NEW(char, nbytes);
        if (op->data.ob_item == NULL) {
            Py_DECREF(op);
            return PyErr_NoMemory();
        }
    }
    return (PyObject *) op;
}
#else
PyObject* newarrayobject(PyTypeObject *type, Py_ssize_t size,
    struct arraydescr *descr);
#endif
static CYTHON_INLINE int resize(arrayobject *self, Py_ssize_t n) {
    void *items = (void*) self->data.ob_item;
    PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize));
    if (items == NULL) {
        PyErr_NoMemory();
        return -1;
    }
    self->data.ob_item = (char*) items;
    self->ob_size = n;
    self->allocated = n;
    return 0;
}
static CYTHON_INLINE int resize_smart(arrayobject *self, Py_ssize_t n) {
    void *items = (void*) self->data.ob_item;
    Py_ssize_t newsize;
    if (n < self->ob_size) {
        self->ob_size = n;
        return 0;
    }
    newsize = n + (n / 2) + 1;
    if (newsize <= self->allocated) {
        PyErr_NoMemory();
        return -1;
    }
    PyMem_Resize(items, char, (size_t)(newsize * self->ob_descr->itemsize));
    if (items == NULL) {
        PyErr_NoMemory();
        return -1;
    }
    self->data.ob_item = (char*) items;
    self->ob_size = n;
    self->allocated = newsize;
    return 0;
}
#endif

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 CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(enum __pyx_t_7plastid_8genomics_8c_common_Strand value);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

static CYTHON_INLINE enum __pyx_t_7plastid_8genomics_8c_common_Strand __Pyx_PyInt_As_enum____pyx_t_7plastid_8genomics_8c_common_Strand(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_ExBool(enum __pyx_t_7plastid_8genomics_8c_common_ExBool value);

#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(__clang__)) && 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 PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);

static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice *mvs,
                                        char order, int ndim);

static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
                                __Pyx_memviewslice *slice2,
                                int ndim, size_t itemsize);

static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
                                 const char *mode, int ndim,
                                 size_t sizeof_dtype, int contig_flag,
                                 int dtype_is_object);

static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);

static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);

static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);

static int __Pyx_ValidateAndInit_memviewslice(
                int *axes_specs,
                int c_or_f_flag,
                int buf_flags,
                int ndim,
                __Pyx_TypeInfo *dtype,
                __Pyx_BufFmt_StackElem stack[],
                __Pyx_memviewslice *memviewslice,
                PyObject *original_obj);

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_long(PyObject *);

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int(PyObject *);

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyObject *);
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(PyTypeObject *type, __pyx_coroutine_body_t body,
                                                   PyObject *closure, PyObject *name, PyObject *qualname);
static int __Pyx_Coroutine_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 PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

static int __Pyx_patch_abc(void);

#define __Pyx_Generator_USED
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_New(body, closure, name, qualname)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, closure, name, qualname)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

static int __Pyx_check_binary_version(void);

#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig);

static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig);

#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);

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

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static int __pyx_f_7plastid_8genomics_8roitools_14GenomicSegment__cmp_helper(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_v_cmptype, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_contains(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_as_igv_str(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_12SegmentChain__set_segments(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments); /* proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain__get_inverse_hash(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto*/
static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_contains(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other); /* proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_shares_segments_with(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other); /* proto*/
static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_unstranded_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other); /* proto*/
static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other); /* proto*/
static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_antisense_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other); /* proto*/
static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_covers(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other); /* proto*/
static struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_get_antisense(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_list(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto*/
static PyArrayObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_array(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, int __pyx_v_copy); /* proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_set(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_get_masked_position_set(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_add_segments(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_12SegmentChain__set_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments); /* proto*/
static void __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_reset_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto*/
static long __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_segmentchain_coordinate(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, long __pyx_v_genomic_x, int __pyx_v_stranded); /* proto*/
static long __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_genomic_coordinate(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, long __pyx_v_x, int __pyx_v_stranded); /* proto*/
static struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_subchain(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, long __pyx_v_start, long __pyx_v_end, int __pyx_v_stranded); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_cds(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_start(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_end(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_genome_start(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto*/
static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_genome_end(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto*/
static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/

/* Module declarations from 'plastid.genomics.c_common' */

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

/* Module declarations from '__builtin__' */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

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

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

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Module declarations from 'cpython' */

/* Module declarations from 'array' */

/* Module declarations from 'cpython.array' */
static PyTypeObject *__pyx_ptype_7cpython_5array_array = 0;
static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobject *, Py_ssize_t, int); /*proto*/
static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobject *, char *, Py_ssize_t); /*proto*/

/* 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 'plastid.genomics.roitools' */
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools_Transcript = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl = 0;
static PyTypeObject *__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr = 0;
static PyTypeObject *__pyx_array_type = 0;
static PyTypeObject *__pyx_MemviewEnum_type = 0;
static PyTypeObject *__pyx_memoryview_type = 0;
static PyTypeObject *__pyx_memoryviewslice_type = 0;
static struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_7plastid_8genomics_8roitools_NullSegment = 0;
static PyObject *__pyx_v_7plastid_8genomics_8roitools_hash_template = 0;
static PyObject *__pyx_v_7plastid_8genomics_8roitools_mask_template = 0;
static PyObject *generic = 0;
static PyObject *strided = 0;
static PyObject *indirect = 0;
static PyObject *contiguous = 0;
static PyObject *indirect_contiguous = 0;
static PyObject *__pyx_f_7plastid_8genomics_8roitools_strand_to_str(enum __pyx_t_7plastid_8genomics_8c_common_Strand); /*proto*/
static enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_f_7plastid_8genomics_8roitools_str_to_strand(PyObject *); /*proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_positions_to_segments(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_f_7plastid_8genomics_8roitools_add_three_for_stop_codon(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *, int __pyx_skip_dispatch); /*proto*/
static void __pyx_f_7plastid_8genomics_8roitools_nonecheck(PyObject *, PyObject *, PyObject *); /*proto*/
static int __pyx_f_7plastid_8genomics_8roitools_check_segments(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, PyObject *); /*proto*/
static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, int); /*proto*/
static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_transcript_richcmp(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *, struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *, int); /*proto*/
static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
static void *__pyx_align_pointer(void *, size_t); /*proto*/
static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
static PyObject *_unellipsify(PyObject *, int); /*proto*/
static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/
static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_LONG_t = { "LONG_t", NULL, sizeof(__pyx_t_7plastid_8genomics_8roitools_LONG_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_7plastid_8genomics_8roitools_LONG_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_7plastid_8genomics_8roitools_LONG_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_DOUBLE_t = { "DOUBLE_t", NULL, sizeof(__pyx_t_7plastid_8genomics_8roitools_DOUBLE_t), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_long = { "long", NULL, sizeof(long), { 0 }, 0, IS_UNSIGNED(long) ? 'U' : 'I', IS_UNSIGNED(long), 0 };
#define __Pyx_MODULE_NAME "plastid.genomics.roitools"
int __pyx_module_is_main_plastid__genomics__roitools = 0;

/* Implementation of 'plastid.genomics.roitools' */
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_DeprecationWarning;
static PyObject *__pyx_builtin_UserWarning;
static PyObject *__pyx_builtin_round;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_all;
static PyObject *__pyx_builtin_any;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_MemoryError;
static PyObject *__pyx_builtin_Ellipsis;
static PyObject *__pyx_builtin_id;
static char __pyx_k_[] = ",";
static char __pyx_k_0[] = "0";
static char __pyx_k_1[] = "1";
static char __pyx_k_B[] = "B";
static char __pyx_k_H[] = "H";
static char __pyx_k_I[] = "I";
static char __pyx_k_L[] = "L";
static char __pyx_k_N[] = "N";
static char __pyx_k_O[] = "O";
static char __pyx_k_Q[] = "Q";
static char __pyx_k_X[] = "X";
static char __pyx_k_b[] = "b";
static char __pyx_k_c[] = "c";
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_v[] = "v";
static char __pyx_k_x[] = "x";
static char __pyx_k_ID[] = "ID";
static char __pyx_k_Zd[] = "Zd";
static char __pyx_k_Zf[] = "Zf";
static char __pyx_k_Zg[] = "Zg";
static char __pyx_k__2[] = "+";
static char __pyx_k__3[] = "-";
static char __pyx_k__4[] = ".";
static char __pyx_k__5[] = "\000";
static char __pyx_k__7[] = ", ";
static char __pyx_k_ga[] = "ga";
static char __pyx_k_id[] = "id";
static char __pyx_k_iv[] = "iv";
static char __pyx_k_na[] = "na";
static char __pyx_k_re[] = "re";
static char __pyx_k_tx[] = "tx";
static char __pyx_k_CDS[] = "CDS";
static char __pyx_k_INT[] = "INT";
static char __pyx_k_Seq[] = "Seq";
static char __pyx_k__12[] = ">";
static char __pyx_k__13[] = "^";
static char __pyx_k__16[] = "";
static char __pyx_k__17[] = "\t";
static char __pyx_k__18[] = "\n";
static char __pyx_k__74[] = "([^:]*):([^(]+)\\(([+-.])\\)";
static char __pyx_k_all[] = "all";
static char __pyx_k_any[] = "any";
static char __pyx_k_end[] = "end";
static char __pyx_k_get[] = "get";
static char __pyx_k_inp[] = "inp";
static char __pyx_k_int[] = "int";
static char __pyx_k_key[] = "key";
static char __pyx_k_nan[] = "nan";
static char __pyx_k_obj[] = "obj";
static char __pyx_k_pop[] = "pop";
static char __pyx_k_s_s[] = "%s='%s'";
static char __pyx_k_seg[] = "seg";
static char __pyx_k_seq[] = "seq";
static char __pyx_k_sum[] = "sum";
static char __pyx_k_tup[] = "tup";
static char __pyx_k_zip[] = "zip";
static char __pyx_k_3UTR[] = "3UTR";
static char __pyx_k_5UTR[] = "5UTR";
static char __pyx_k_LONG[] = "LONG";
static char __pyx_k_Name[] = "Name";
static char __pyx_k_None[] = "None";
static char __pyx_k_args[] = "args";
static char __pyx_k_attr[] = "attr";
static char __pyx_k_base[] = "base";
static char __pyx_k_copy[] = "copy";
static char __pyx_k_dtmp[] = "dtmp";
static char __pyx_k_exon[] = "exon";
static char __pyx_k_func[] = "func";
static char __pyx_k_intc[] = "intc";
static char __pyx_k_join[] = "join";
static char __pyx_k_line[] = "line";
static char __pyx_k_long[] = "long";
static char __pyx_k_ltmp[] = "ltmp";
static char __pyx_k_mRNA[] = "mRNA";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_mask[] = "mask";
static char __pyx_k_mode[] = "mode";
static char __pyx_k_name[] = "__name__";
static char __pyx_k_ndim[] = "ndim";
static char __pyx_k_next[] = "__next__";
static char __pyx_k_none[] = "none";
static char __pyx_k_pack[] = "pack";
static char __pyx_k_segs[] = "segs";
static char __pyx_k_send[] = "send";
static char __pyx_k_size[] = "size";
static char __pyx_k_step[] = "step";
static char __pyx_k_stmp[] = "stmp";
static char __pyx_k_stop[] = "stop";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_type[] = "type";
static char __pyx_k_warn[] = "warn";
static char __pyx_k_0_0_0[] = "0,0,0";
static char __pyx_k_ASCII[] = "ASCII";
static char __pyx_k_FLOAT[] = "FLOAT";
static char __pyx_k_array[] = "array";
static char __pyx_k_chrom[] = "chrom";
static char __pyx_k_class[] = "__class__";
static char __pyx_k_close[] = "close";
static char __pyx_k_color[] = "color";
static char __pyx_k_dtype[] = "dtype";
static char __pyx_k_error[] = "error";
static char __pyx_k_flags[] = "flags";
static char __pyx_k_float[] = "float";
static char __pyx_k_frags[] = "frags";
static char __pyx_k_frame[] = "frame";
static char __pyx_k_isnan[] = "isnan";
static char __pyx_k_items[] = "items";
static char __pyx_k_numpy[] = "numpy";
static char __pyx_k_other[] = "other";
static char __pyx_k_phase[] = "phase";
static char __pyx_k_piece[] = "piece";
static char __pyx_k_range[] = "range";
static char __pyx_k_round[] = "round";
static char __pyx_k_s_end[] = "s_end";
static char __pyx_k_s_s_2[] = "%s-%s";
static char __pyx_k_s_s_3[] = ">%s\n%s\n";
static char __pyx_k_s_s_s[] = "%s:%s-%s";
static char __pyx_k_score[] = "score";
static char __pyx_k_shape[] = "shape";
static char __pyx_k_split[] = "split";
static char __pyx_k_start[] = "start";
static char __pyx_k_strip[] = "strip";
static char __pyx_k_throw[] = "throw";
static char __pyx_k_types[] = "types";
static char __pyx_k_zeros[] = "zeros";
static char __pyx_k_000000[] = "#000000";
static char __pyx_k_DOUBLE[] = "DOUBLE";
static char __pyx_k_Parent[] = "Parent";
static char __pyx_k_as_bed[] = "as_bed";
static char __pyx_k_as_gtf[] = "as_gtf";
static char __pyx_k_as_int[] = "as_int";
static char __pyx_k_astype[] = "astype";
static char __pyx_k_blocks[] = "blocks";
static char __pyx_k_copy_2[] = "__copy__";
static char __pyx_k_double[] = "double";
static char __pyx_k_encode[] = "encode";
static char __pyx_k_escape[] = "escape";
static char __pyx_k_format[] = "format";
static char __pyx_k_genome[] = "genome";
static char __pyx_k_groups[] = "groups";
static char __pyx_k_igvpat[] = "igvpat";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_ivcpat[] = "ivcpat";
static char __pyx_k_middle[] = "middle";
static char __pyx_k_name_2[] = "name";
static char __pyx_k_name_s[] = " name=%s";
static char __pyx_k_s_3UTR[] = "%s_3UTR";
static char __pyx_k_s_5UTR[] = "%s_5UTR";
static char __pyx_k_search[] = "search";
static char __pyx_k_segpat[] = "segpat";
static char __pyx_k_source[] = "source";
static char __pyx_k_sstart[] = "sstart";
static char __pyx_k_strand[] = "strand";
static char __pyx_k_struct[] = "struct";
static char __pyx_k_tolist[] = "tolist";
static char __pyx_k_unpack[] = "unpack";
static char __pyx_k_update[] = "update";
static char __pyx_k_values[] = "values";
static char __pyx_k_0_9_0_9[] = "([^:]*):([0-9]+)-([0-9]+)";
static char __pyx_k_Bio_Seq[] = "Bio.Seq";
static char __pyx_k_as_gff3[] = "as_gff3";
static char __pyx_k_asarray[] = "asarray";
static char __pyx_k_cmptype[] = "cmptype";
static char __pyx_k_compile[] = "compile";
static char __pyx_k_default[] = "default";
static char __pyx_k_fortran[] = "fortran";
static char __pyx_k_gene__s[] = "gene_%s";
static char __pyx_k_gene_id[] = "gene_id";
static char __pyx_k_genexpr[] = "genexpr";
static char __pyx_k_get_cds[] = "get_cds";
static char __pyx_k_getitem[] = "__getitem__";
static char __pyx_k_iv_ltmp[] = "iv_ltmp";
static char __pyx_k_loc_str[] = "loc_str";
static char __pyx_k_memview[] = "memview";
static char __pyx_k_s_s_s_2[] = "%s:%s(%s)";
static char __pyx_k_s_s_s_3[] = "%s,%s,%s";
static char __pyx_k_s_s_s_4[] = "%s:%s:%s";
static char __pyx_k_s_s_s_s[] = "%s:%s-%s(%s)";
static char __pyx_k_s_start[] = "s_start";
static char __pyx_k_segment[] = "segment";
static char __pyx_k_t_start[] = "t_start";
static char __pyx_k_Ellipsis[] = "Ellipsis";
static char __pyx_k_KeyError[] = "KeyError";
static char __pyx_k_c_strand[] = "c_strand";
static char __pyx_k_contains[] = "contains";
static char __pyx_k_custom_s[] = "custom%s";
static char __pyx_k_deepcopy[] = "deepcopy";
static char __pyx_k_excludes[] = "excludes";
static char __pyx_k_frag_end[] = "frag_end";
static char __pyx_k_from_bed[] = "from_bed";
static char __pyx_k_from_psl[] = "from_psl";
static char __pyx_k_from_str[] = "from_str";
static char __pyx_k_get_attr[] = "_get_attr";
static char __pyx_k_get_gene[] = "get_gene";
static char __pyx_k_get_name[] = "get_name";
static char __pyx_k_get_utr3[] = "get_utr3";
static char __pyx_k_get_utr5[] = "get_utr5";
static char __pyx_k_getstate[] = "__getstate__";
static char __pyx_k_itemsize[] = "itemsize";
static char __pyx_k_numpy_ma[] = "numpy.ma";
static char __pyx_k_overlaps[] = "overlaps";
static char __pyx_k_psl_line[] = "psl_line";
static char __pyx_k_pyx_capi[] = "__pyx_capi__";
static char __pyx_k_q_starts[] = "q_starts";
static char __pyx_k_rna_type[] = "rna_type";
static char __pyx_k_s_exon_s[] = "%s:exon:%s";
static char __pyx_k_segchain[] = "segchain";
static char __pyx_k_segments[] = "segments";
static char __pyx_k_stranded[] = "stranded";
static char __pyx_k_t_starts[] = "t_starts";
static char __pyx_k_thickend[] = "thickend";
static char __pyx_k_warnings[] = "warnings";
static char __pyx_k_0_9_0_9_2[] = "([^:]*):([0-9]+)-([0-9]+)\\(([+-.])\\)";
static char __pyx_k_None_None[] = "None:(None)";
static char __pyx_k_SeqRecord[] = "SeqRecord";
static char __pyx_k_TypeError[] = "TypeError";
static char __pyx_k_alignment[] = "alignment";
static char __pyx_k_attr_dict[] = "attr: dict";
static char __pyx_k_chrom_end[] = "chrom_end";
static char __pyx_k_enumerate[] = "enumerate";
static char __pyx_k_formatter[] = "formatter";
static char __pyx_k_genomic_x[] = "genomic_x";
static char __pyx_k_num_frags[] = "num_frags";
static char __pyx_k_positions[] = "positions";
static char __pyx_k_query_end[] = "query_end";
static char __pyx_k_roi_order[] = "roi_order";
static char __pyx_k_IndexError[] = "IndexError";
static char __pyx_k_ValueError[] = "ValueError";
static char __pyx_k_as_igv_str[] = "as_igv_str";
static char __pyx_k_block_size[] = "block_size";
static char __pyx_k_blocksizes[] = "blocksizes";
static char __pyx_k_cmp_helper[] = "_cmp_helper";
static char __pyx_k_contains_2[] = "__contains__";
static char __pyx_k_default_id[] = "default_id";
static char __pyx_k_deprecated[] = "deprecated";
static char __pyx_k_frag_sizes[] = "frag_sizes";
static char __pyx_k_frag_start[] = "frag_start";
static char __pyx_k_frombuffer[] = "frombuffer";
static char __pyx_k_get_counts[] = "get_counts";
static char __pyx_k_get_length[] = "get_length";
static char __pyx_k_get_rgb255[] = "get_rgb255";
static char __pyx_k_mismatches[] = "mismatches";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_query_name[] = "query_name";
static char __pyx_k_s_subchain[] = "%s_subchain";
static char __pyx_k_stop_codon[] = "stop_codon";
static char __pyx_k_target_end[] = "target_end";
static char __pyx_k_thickstart[] = "thickstart";
static char __pyx_k_transcript[] = "transcript";
static char __pyx_k_DataWarning[] = "DataWarning";
static char __pyx_k_MaskedArray[] = "MaskedArray";
static char __pyx_k_MemoryError[] = "MemoryError";
static char __pyx_k_NullSegment[] = "NullSegment";
static char __pyx_k_UserWarning[] = "UserWarning";
static char __pyx_k_bed_columns[] = "bed_columns";
static char __pyx_k_block_sizes[] = "block_sizes";
static char __pyx_k_blockstarts[] = "blockstarts";
static char __pyx_k_chrom_start[] = "chrom_start";
static char __pyx_k_generic_dna[] = "generic_dna";
static char __pyx_k_query_start[] = "query_start";
static char __pyx_k_rep_matches[] = "rep_matches";
static char __pyx_k_start_codon[] = "start_codon";
static char __pyx_k_target_name[] = "target_name";
static char __pyx_k_Bio_Alphabet[] = "Bio.Alphabet";
static char __pyx_k_RuntimeError[] = "RuntimeError";
static char __pyx_k_block_starts[] = "block_starts";
static char __pyx_k_feature_type[] = "feature_type";
static char __pyx_k_frag_offsets[] = "frag_offsets";
static char __pyx_k_from_igv_str[] = "from_igv_str";
static char __pyx_k_get_sequence[] = "get_sequence";
static char __pyx_k_get_subchain[] = "get_subchain";
static char __pyx_k_match_length[] = "match_length";
static char __pyx_k_query_length[] = "query_length";
static char __pyx_k_s_segments_s[] = "<%s segments=%s";
static char __pyx_k_staticmethod[] = "staticmethod";
static char __pyx_k_target_start[] = "target_start";
static char __pyx_k_Bio_SeqRecord[] = "Bio.SeqRecord";
static char __pyx_k_extra_columns[] = "extra_columns";
static char __pyx_k_get_antisense[] = "get_antisense";
static char __pyx_k_get_junctions[] = "get_junctions";
static char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
static char __pyx_k_target_length[] = "target_length";
static char __pyx_k_transcript_id[] = "transcript_id";
static char __pyx_k_AttributeError[] = "AttributeError";
static char __pyx_k_GenomicSegment[] = "GenomicSegment";
static char __pyx_k_NullChromosome[] = "NullChromosome";
static char __pyx_k_bounds_s_s_s_s[] = " bounds=%s:%s-%s(%s)";
static char __pyx_k_cds_genome_end[] = "cds_genome_end";
static char __pyx_k_five_prime_UTR[] = "five_prime_UTR";
static char __pyx_k_allocate_buffer[] = "allocate_buffer";
static char __pyx_k_dtype_is_object[] = "dtype_is_object";
static char __pyx_k_num_bed_columns[] = "num_bed_columns";
static char __pyx_k_query_gap_bases[] = "query_gap_bases";
static char __pyx_k_query_gap_count[] = "query_gap_count";
static char __pyx_k_three_prime_UTR[] = "three_prime_UTR";
static char __pyx_k_SegmentChain_s_s[] = "SegmentChain(%s,%s)";
static char __pyx_k_cds_genome_start[] = "cds_genome_start";
static char __pyx_k_get_str_from_rgb[] = "get_str_from_rgb";
static char __pyx_k_make_GFF3_tokens[] = "make_GFF3_tokens";
static char __pyx_k_make_GTF2_tokens[] = "make_GTF2_tokens";
static char __pyx_k_s_s_s_s_strand_s[] = "<%s %s:%s-%s strand='%s'>";
static char __pyx_k_strand_undefined[] = "strand undefined";
static char __pyx_k_target_gap_bases[] = "target_gap_bases";
static char __pyx_k_target_gap_count[] = "target_gap_count";
static char __pyx_k_bedx_column_order[] = "_bedx_column_order";
static char __pyx_k_column_formatters[] = "column_formatters";
static char __pyx_k_format_transcript[] = "_format_transcript";
static char __pyx_k_get_8_gff_columns[] = "_get_8_gff_columns";
static char __pyx_k_get_position_list[] = "get_position_list";
static char __pyx_k_num_extra_columns[] = "num_extra_columns";
static char __pyx_k_DeprecationWarning[] = "DeprecationWarning";
static char __pyx_k_reverse_complement[] = "reverse_complement";
static char __pyx_k_strided_and_direct[] = "<strided and direct>";
static char __pyx_k_GenomicSegment___eq[] = "GenomicSegment.__eq__";
static char __pyx_k_format_segmentchain[] = "_format_segmentchain";
static char __pyx_k_get_str_from_rgb255[] = "get_str_from_rgb255";
static char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
static char __pyx_k_GenomicSegment_eq_neq[] = "GenomicSegment eq/neq";
static char __pyx_k_as_bed_locals_genexpr[] = "as_bed.<locals>.genexpr";
static char __pyx_k_as_psl_locals_genexpr[] = "as_psl.<locals>.genexpr";
static char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
static char __pyx_k_GenomicSegment_s_s_s_s[] = "GenomicSegment('%s',%s,%s,'%s')";
static char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
static char __pyx_k_GenomicSegment_contains[] = "GenomicSegment.contains";
static char __pyx_k_GenomicSegment_overlaps[] = "GenomicSegment.overlaps";
static char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
static char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
static char __pyx_k_get_masked_position_set[] = "get_masked_position_set";
static char __pyx_k_plastid_plotting_colors[] = "plastid.plotting.colors";
static char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
static char __pyx_k_getbuffer_obj_view_flags[] = "getbuffer(obj, view, flags)";
static char __pyx_k_Dimension_d_is_not_direct[] = "Dimension %d is not direct";
static char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
static char __pyx_k_plastid_genomics_roitools[] = "plastid.genomics.roitools";
static char __pyx_k_Index_out_of_bounds_axis_d[] = "Index out of bounds (axis %d)";
static char __pyx_k_Strand_of_the_SegmentChain[] = "Strand of the SegmentChain";
static char __pyx_k_plastid_readers_gff_tokens[] = "plastid.readers.gff_tokens";
static char __pyx_k_Step_may_not_be_zero_axis_d[] = "Step may not be zero (axis %d)";
static char __pyx_k_get_segmentchain_coordinate[] = "get_segmentchain_coordinate";
static char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
static char __pyx_k_s_value_of_s_cannot_be_None[] = "%s: value of %s cannot be None";
static char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
static char __pyx_k_wrong_and_or_multiple_strands[] = "; wrong and/or multiple strands";
static char __pyx_k_s_get_length_is_deprecated_and[] = "%s.get_length() is deprecated and will be removed in future versions. Use %s.length property instead";
static char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
static char __pyx_k_Chromosome_where_GenomicSegment[] = "Chromosome where |GenomicSegment| resides";
static char __pyx_k_Copy_of_list_of_GenomicSegments[] = "Copy of list of |GenomicSegments| that comprise `self`.\n        Changing this list will do nothing to `self`.\n        ";
static char __pyx_k_GenomicSegment_start_coordinate[] = "GenomicSegment: start coordinate (%s) must be >= end (%s).";
static char __pyx_k_SegmentChain_antisense_overlaps[] = "SegmentChain.antisense_overlaps() errored on chain '%s' and object '%s'";
static char __pyx_k_Segmentchain_adding_segments_to[] = "Segmentchain: adding segments to %s will reset its masks!";
static char __pyx_k_Start_of_coding_region_relative[] = "Start of coding region relative to 5' end of transcript, in direction of transcript.\n        Setting to None also sets `self.cds_end`, `self.cds_genome_start` and\n        `self.cds_genome_end` to None\n        ";
static char __pyx_k_Strand_must_be_or_x00_undefined[] = "Strand must be '+', '-', '.', or '\\x00' (undefined)";
static char __pyx_k_Transcript_s_cds_genome_start_s[] = "Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)";
static char __pyx_k_Zero_indexed_half_open_Pythonic[] = "Zero-indexed, half-open (Pythonic) end coordinate of |GenomicSegment|";
static char __pyx_k_end_coordinate_supplied_is_None[] = "end coordinate supplied is None. Expected int";
static char __pyx_k_homeroot_joshua_projects_plasti[] = "/homeroot/joshua/projects/plastid/plastid/genomics/roitools.pyx";
static char __pyx_k_s_get_masked_length_is_deprecat[] = "%s.get_masked_length() is deprecated and will be removed in future versions. Use %s.masked_length property instead";
static char __pyx_k_s_is_a_zero_length_SegmentChain[] = "%s is a zero-length SegmentChain. Returning 0-length count vector.";
static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_wrong_and_or_multiple_chromosom[] = "; wrong and/or multiple chromosomes";
static char __pyx_k_All_dimensions_preceding_dimensi[] = "All dimensions preceding dimension %d must be indexed and not sliced";
static char __pyx_k_Attempted_export_of_multi_interv[] = "Attempted export of multi-interval %s";
static char __pyx_k_BED_format_requires_at_least_3_c[] = "BED format requires at least 3 columns. Found only %s.";
static char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
static char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
static char __pyx_k_Cannot_fetch_coordinate_s_from_S[] = "Cannot fetch coordinate %s from SegmentChain %s (length %s)";
static char __pyx_k_Cannot_make_SegmentChain_from_BE[] = "Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.";
static char __pyx_k_Cannot_transpose_memoryview_with[] = "Cannot transpose memoryview with indirect dimensions";
static char __pyx_k_Chromosome_the_SegmentChain_resi[] = "Chromosome the SegmentChain resides on";
static char __pyx_k_Comparison_operation_not_defined[] = "Comparison operation not defined";
static char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
static char __pyx_k_End_of_coding_region_relative_to[] = "End of coding region relative to 5' end of transcript, in direction of transcript.\n        Setting to None also sets `self.cds_start`, `self.cds_genome_start` and\n        `self.cds_genome_end` to None\n        ";
static char __pyx_k_Ending_coordinate_of_coding_regi[] = "Ending coordinate of coding region, relative to genome (i.e. leftmost;\n        is stop codon for forward-strand features, start codon for reverse-strand\n        features. Setting to None also sets `self.cds_start`, `self.cds_end`,\n        and `self.cds_genome_start` to None\n        ";
static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
static char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
static char __pyx_k_List_of_extra_columns_contains_m[] = "List of `extra_columns` contains mixed types. Cannot parse.";
static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
static char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
static char __pyx_k_Position_s_is_outside_bounds_0_s[] = "Position %s is outside bounds [0,%s) of SegmentChain '%s'";
static char __pyx_k_SegmentChain_add_segments_incomi[] = "SegmentChain.add_segments: incoming segments (%s) mismatch chain '%s'";
static char __pyx_k_SegmentChain_covers_is_only_defi[] = "SegmentChain.covers() is only defined for GenomicSegments and SegmentChains. Found %s.";
static char __pyx_k_SegmentChain_eq_ineq_et_c_is_onl[] = "SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.";
static char __pyx_k_SegmentChain_get_segmentchain_co[] = "SegmentChain.get_segmentchain_coordinate: Genomic position %s not in SegmentChain %s.";
static char __pyx_k_SegmentChain_overlaps_is_defined[] = "SegmentChain.overlaps() is defined only for GenomicSegments and SegmentChains. Found %s.";
static char __pyx_k_SegmentChain_shares_segments_wit[] = "SegmentChain.shares_segments_with() is defined only for GenomicSegments and SegmentChains. Found %s.";
static char __pyx_k_SegmentChain_unstranded_overlaps[] = "SegmentChain.unstranded_overlaps() errored on chain '%s' and object '%s'";
static char __pyx_k_SegmentChains_only_support_PSL_o[] = "SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end";
static char __pyx_k_Starting_coordinate_of_coding_re[] = "Starting coordinate of coding region, relative to genome (i.e. leftmost;\n        is start codon for forward-strand features, stop codon for reverse-strand\n        features). Setting to None also sets `self.cds_start`, `self.cds_end`, and\n        `self.cds_genome_end` to None\n        ";
static char __pyx_k_Strand_for_SegmentChain_s_is_und[] = "Strand for SegmentChain '%s' is undefined and has no anti-sense.";
static char __pyx_k_Strand_of_GenomicSegment_for_for[] = "Strand of |GenomicSegment|:\n\n          - '+' for forward / Watson strand\n          - '-' for reverse / Crick strand\n          - '.' for unstranded / both strands\n        ";
static char __pyx_k_The_in_containment_operator_is_o[] = "The 'in'/containment operator is only defined for GenomicSegments and SegmentChains";
static char __pyx_k_This_module_defines_object_types[] = "This module defines object types that describe features in a genome or contig.\n\n\nImportant classes\n-----------------\n|GenomicSegment|\n    A fundamental unit of a feature, similar to :py:class:`HTSeq.GenomicInterval`.\n    |GenomicSegment| describes a single region of a genome, and is fully specified\n    by a chromosome name, a start coordinate, an end coordinate, and a strand.\n    \n    |GenomicSegments| provide no feature annotation data, and are used\n    primarily to construct |SegmentChains| or |Transcripts|, which do\n    provide feature annotation data. |GenomicSegment| implements various methods\n    to test equality to, overlap with, and containment of other |GenomicSegment|\n    objects.\n\n|SegmentChain|\n    Base class for genomic features with rich annotation data. |SegmentChains|\n    can contain zero or more |GenomicSegments|, and can therefore model\n    discontinuous features -- such as multi-exon transcripts or gapped alignments --\n    in addition to continuous features.  \n    \n    |SegmentChain| implements numerous convenience methods, e.g. for:\n\n        - Converting coordinates between the genome and the spliced space of the\n          |SegmentChain|\n        \n        - Fetching genomic sequence, read alignments, or count data over\n          the |SegmentChain|, accounting for splicing of the segments and, for\n          reverse-strand features, reverse-complementing of sequence\n\n        - Slicing or fetching sub-regions of a |SegmentChain|\n          \n        - Testing for equality, inequality, overlap, containment, or coverage\n          of other |SegmentChain| or |GenomicSegment| objects, in stranded \n          or unstranded manners\n          \n        - Exporting to `BED`_, `GTF2`_, or `GFF3`_ formats, for use with other\n          software packages or within a genome browser.\n\n    In addition, |SegmentChain| objects have attribute dictionaries that allow\n    sotrage of arbitrary annotation information (e.g. gene IDs, GO ""terms, database\n    cross-references, or miscellaneous notes).\n\n|Transcript|\n     Subclass of |SegmentChain| that adds convenience methods for fetching CDS,\n     5' UTRs, and 3' UTRs, if the transcript is coding.\n\n\nExamples\n--------\nConstruct a |SegmentChain| from |GenomicSegments|::\n\n    >>>\n    >>>\n    \n\nFetch a vector of spliced counts covering a |SegmentChain| from a |GenomeHash|::\n\n    >>>\n    >>>\n\n\nFetch a sub-region of a chain::\n\n    >>>\n    >>>\n\n\nFind genomic coordinate of position 53 in a chain::\n\n    >>>\n    >>>\n\n\n";
static char __pyx_k_This_operation_is_not_defined_fo[] = "This operation is not defined for SegmentChains.";
static char __pyx_k_Transcript_s_ID_s_cds_genome_sta[] = "Transcript(%s,ID='%s',cds_genome_start=%s,cds_genome_end=%s)";
static char __pyx_k_Transcript_s_cds_end_s_must_be_c[] = "Transcript '%s': cds_end (%s) must be >= cds_start (%s)";
static char __pyx_k_Transcript_s_cds_end_s_must_be_s[] = "Transcript '%s': cds_end (%s) must be <= self.length (%s)";
static char __pyx_k_Transcript_s_cds_genome_end_s_mu[] = "Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)";
static char __pyx_k_Transcript_s_cds_start_s_must_be[] = "Transcript '%s': cds_start (%s) must be <= cds_end (%s)";
static char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
static char __pyx_k_Zero_indexed_Pythonic_start_coor[] = "Zero-indexed (Pythonic) start coordinate of |GenomicSegment|";
static char __pyx_k_get_segmentchain_coordinate_quer[] = "get_segmentchain_coordinate: query chromosome '%s' does not match chain '%s'";
static char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
static char __pyx_k_plastid_util_services_decorators[] = "plastid.util.services.decorators";
static char __pyx_k_plastid_util_services_exceptions[] = "plastid.util.services.exceptions";
static char __pyx_k_start_coordinate_supplied_is_Non[] = "start coordinate supplied is None. Expected int";
static char __pyx_k_strand_to_str_Strand_must_be_for[] = "strand_to_str: Strand must be forward (%s), reverse (%s), or unstranded(%s). Got '%s'";
static char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
static char __pyx_k_Copy_of_list_of_GenomicSegments_2[] = "Copy of list of |GenomicSegments| representing regions masked in `self.`\n        Changing this list will do nothing to the masks in `self`.\n        ";
static char __pyx_k_SegmentChain_antisense_overlaps_2[] = "SegmentChain.antisense_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s.";
static char __pyx_k_s_is_a_zero_length_SegmentChain_2[] = "%s is a zero-length SegmentChain. Returning empty sequence.";
static char __pyx_k_Cannot_make_SegmentChain_from_BE_2[] = "Cannot make SegmentChain from BED input: if a list, extra_columns must be a list of tuples of (column_name,formatter_func)";
static char __pyx_k_Cannot_make_SegmentChain_from_BE_3[] = "Cannot make SegmentChain from BED input: extra_columns must be an int or list. Got a %s";
static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
static char __pyx_k_SegmentChain_get_segmentchain_co_2[] = "SegmentChain.get_segmentchain_coordinate: genomic position '%s' is not in chain '%s'.";
static char __pyx_k_SegmentChain_unstranded_overlaps_2[] = "SegmentChain.unstranded_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s.";
static char __pyx_k_This_operation_is_not_defined_fo_2[] = "This operation is not defined for Transcripts.";
static char __pyx_k_Transcript_s_cds_start_s_must_be_2[] = "Transcript '%s': cds_start (%s) must be >= 0";
static char __pyx_k_get_segmentchain_coordinate_quer_2[] = "get_segmentchain_coordinate: query strand '%s' does not match chain '%s'";
static PyObject *__pyx_kp_s_;
static PyObject *__pyx_kp_s_0;
static PyObject *__pyx_kp_s_000000;
static PyObject *__pyx_kp_s_0_0_0;
static PyObject *__pyx_kp_s_0_9_0_9;
static PyObject *__pyx_kp_s_0_9_0_9_2;
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_3UTR;
static PyObject *__pyx_kp_s_5UTR;
static PyObject *__pyx_n_s_ASCII;
static PyObject *__pyx_kp_s_Attempted_export_of_multi_interv;
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_kp_s_BED_format_requires_at_least_3_c;
static PyObject *__pyx_n_s_Bio_Alphabet;
static PyObject *__pyx_n_s_Bio_Seq;
static PyObject *__pyx_n_s_Bio_SeqRecord;
static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
static PyObject *__pyx_n_s_CDS;
static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
static PyObject *__pyx_kp_s_Cannot_fetch_coordinate_s_from_S;
static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
static PyObject *__pyx_kp_s_Cannot_make_SegmentChain_from_BE;
static PyObject *__pyx_kp_s_Cannot_make_SegmentChain_from_BE_2;
static PyObject *__pyx_kp_s_Cannot_make_SegmentChain_from_BE_3;
static PyObject *__pyx_kp_s_Comparison_operation_not_defined;
static PyObject *__pyx_n_s_DOUBLE;
static PyObject *__pyx_n_s_DataWarning;
static PyObject *__pyx_n_s_DeprecationWarning;
static PyObject *__pyx_n_s_Ellipsis;
static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
static PyObject *__pyx_n_s_FLOAT;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
static PyObject *__pyx_n_s_GenomicSegment;
static PyObject *__pyx_kp_s_GenomicSegment___eq;
static PyObject *__pyx_kp_s_GenomicSegment_contains;
static PyObject *__pyx_kp_s_GenomicSegment_eq_neq;
static PyObject *__pyx_kp_s_GenomicSegment_overlaps;
static PyObject *__pyx_kp_s_GenomicSegment_s_s_s_s;
static PyObject *__pyx_kp_s_GenomicSegment_start_coordinate;
static PyObject *__pyx_n_s_ID;
static PyObject *__pyx_n_s_INT;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_LONG;
static PyObject *__pyx_kp_s_List_of_extra_columns_contains_m;
static PyObject *__pyx_n_s_MaskedArray;
static PyObject *__pyx_n_s_MemoryError;
static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
static PyObject *__pyx_kp_s_MemoryView_of_r_object;
static PyObject *__pyx_n_s_N;
static PyObject *__pyx_n_s_Name;
static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
static PyObject *__pyx_n_s_None;
static PyObject *__pyx_kp_s_None_None;
static PyObject *__pyx_n_s_NullChromosome;
static PyObject *__pyx_n_s_NullSegment;
static PyObject *__pyx_n_b_O;
static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
static PyObject *__pyx_n_s_Parent;
static PyObject *__pyx_kp_s_Position_s_is_outside_bounds_0_s;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_s_SegmentChain_add_segments_incomi;
static PyObject *__pyx_kp_s_SegmentChain_antisense_overlaps;
static PyObject *__pyx_kp_s_SegmentChain_antisense_overlaps_2;
static PyObject *__pyx_kp_s_SegmentChain_covers_is_only_defi;
static PyObject *__pyx_kp_s_SegmentChain_eq_ineq_et_c_is_onl;
static PyObject *__pyx_kp_s_SegmentChain_get_segmentchain_co;
static PyObject *__pyx_kp_s_SegmentChain_get_segmentchain_co_2;
static PyObject *__pyx_kp_s_SegmentChain_overlaps_is_defined;
static PyObject *__pyx_kp_s_SegmentChain_s_s;
static PyObject *__pyx_kp_s_SegmentChain_shares_segments_wit;
static PyObject *__pyx_kp_s_SegmentChain_unstranded_overlaps;
static PyObject *__pyx_kp_s_SegmentChain_unstranded_overlaps_2;
static PyObject *__pyx_kp_s_SegmentChains_only_support_PSL_o;
static PyObject *__pyx_kp_s_Segmentchain_adding_segments_to;
static PyObject *__pyx_n_s_Seq;
static PyObject *__pyx_n_s_SeqRecord;
static PyObject *__pyx_kp_s_Strand_for_SegmentChain_s_is_und;
static PyObject *__pyx_kp_s_Strand_must_be_or_x00_undefined;
static PyObject *__pyx_kp_s_The_in_containment_operator_is_o;
static PyObject *__pyx_kp_s_This_operation_is_not_defined_fo;
static PyObject *__pyx_kp_s_This_operation_is_not_defined_fo_2;
static PyObject *__pyx_kp_s_Transcript_s_ID_s_cds_genome_sta;
static PyObject *__pyx_kp_s_Transcript_s_cds_end_s_must_be_c;
static PyObject *__pyx_kp_s_Transcript_s_cds_end_s_must_be_s;
static PyObject *__pyx_kp_s_Transcript_s_cds_genome_end_s_mu;
static PyObject *__pyx_kp_s_Transcript_s_cds_genome_start_s;
static PyObject *__pyx_kp_s_Transcript_s_cds_start_s_must_be;
static PyObject *__pyx_kp_s_Transcript_s_cds_start_s_must_be_2;
static PyObject *__pyx_n_s_TypeError;
static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
static PyObject *__pyx_n_s_UserWarning;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_X;
static PyObject *__pyx_kp_s__12;
static PyObject *__pyx_kp_s__13;
static PyObject *__pyx_kp_s__16;
static PyObject *__pyx_kp_s__17;
static PyObject *__pyx_kp_s__18;
static PyObject *__pyx_kp_s__2;
static PyObject *__pyx_kp_s__3;
static PyObject *__pyx_kp_s__4;
static PyObject *__pyx_kp_s__5;
static PyObject *__pyx_kp_s__7;
static PyObject *__pyx_kp_s__74;
static PyObject *__pyx_n_s_alignment;
static PyObject *__pyx_n_s_all;
static PyObject *__pyx_n_s_allocate_buffer;
static PyObject *__pyx_n_s_any;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_array;
static PyObject *__pyx_n_s_as_bed;
static PyObject *__pyx_n_s_as_bed_locals_genexpr;
static PyObject *__pyx_n_s_as_gff3;
static PyObject *__pyx_n_s_as_gtf;
static PyObject *__pyx_n_s_as_igv_str;
static PyObject *__pyx_n_s_as_int;
static PyObject *__pyx_n_s_as_psl_locals_genexpr;
static PyObject *__pyx_n_s_asarray;
static PyObject *__pyx_n_s_astype;
static PyObject *__pyx_n_s_attr;
static PyObject *__pyx_n_s_base;
static PyObject *__pyx_n_s_bed_columns;
static PyObject *__pyx_n_s_bedx_column_order;
static PyObject *__pyx_n_s_block_size;
static PyObject *__pyx_n_s_block_sizes;
static PyObject *__pyx_n_s_block_starts;
static PyObject *__pyx_n_s_blocks;
static PyObject *__pyx_n_s_blocksizes;
static PyObject *__pyx_n_s_blockstarts;
static PyObject *__pyx_kp_s_bounds_s_s_s_s;
static PyObject *__pyx_n_s_c;
static PyObject *__pyx_n_u_c;
static PyObject *__pyx_n_s_c_strand;
static PyObject *__pyx_n_s_cds_genome_end;
static PyObject *__pyx_n_s_cds_genome_start;
static PyObject *__pyx_n_s_chrom;
static PyObject *__pyx_n_s_chrom_end;
static PyObject *__pyx_n_s_chrom_start;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_cmp_helper;
static PyObject *__pyx_n_s_cmptype;
static PyObject *__pyx_n_s_color;
static PyObject *__pyx_n_s_column_formatters;
static PyObject *__pyx_n_s_compile;
static PyObject *__pyx_n_s_contains;
static PyObject *__pyx_n_s_contains_2;
static PyObject *__pyx_kp_s_contiguous_and_direct;
static PyObject *__pyx_kp_s_contiguous_and_indirect;
static PyObject *__pyx_n_s_copy;
static PyObject *__pyx_n_s_copy_2;
static PyObject *__pyx_kp_s_custom_s;
static PyObject *__pyx_n_s_deepcopy;
static PyObject *__pyx_n_s_default;
static PyObject *__pyx_n_s_default_id;
static PyObject *__pyx_n_s_deprecated;
static PyObject *__pyx_n_s_double;
static PyObject *__pyx_n_s_dtmp;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dtype_is_object;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_kp_s_end_coordinate_supplied_is_None;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_n_s_escape;
static PyObject *__pyx_n_s_excludes;
static PyObject *__pyx_n_s_exon;
static PyObject *__pyx_n_s_extra_columns;
static PyObject *__pyx_n_s_feature_type;
static PyObject *__pyx_n_s_five_prime_UTR;
static PyObject *__pyx_n_s_flags;
static PyObject *__pyx_n_s_float;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_format_segmentchain;
static PyObject *__pyx_n_s_format_transcript;
static PyObject *__pyx_n_s_formatter;
static PyObject *__pyx_n_s_fortran;
static PyObject *__pyx_n_u_fortran;
static PyObject *__pyx_n_s_frag_end;
static PyObject *__pyx_n_s_frag_offsets;
static PyObject *__pyx_n_s_frag_sizes;
static PyObject *__pyx_n_s_frag_start;
static PyObject *__pyx_n_s_frags;
static PyObject *__pyx_n_s_frame;
static PyObject *__pyx_n_s_from_bed;
static PyObject *__pyx_n_s_from_igv_str;
static PyObject *__pyx_n_s_from_psl;
static PyObject *__pyx_n_s_from_str;
static PyObject *__pyx_n_s_frombuffer;
static PyObject *__pyx_n_s_func;
static PyObject *__pyx_n_s_ga;
static PyObject *__pyx_kp_s_gene__s;
static PyObject *__pyx_n_s_gene_id;
static PyObject *__pyx_n_s_generic_dna;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_genome;
static PyObject *__pyx_n_s_genomic_x;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_get_8_gff_columns;
static PyObject *__pyx_n_s_get_antisense;
static PyObject *__pyx_n_s_get_attr;
static PyObject *__pyx_n_s_get_cds;
static PyObject *__pyx_n_s_get_counts;
static PyObject *__pyx_n_s_get_gene;
static PyObject *__pyx_n_s_get_junctions;
static PyObject *__pyx_n_s_get_length;
static PyObject *__pyx_n_s_get_masked_position_set;
static PyObject *__pyx_n_s_get_name;
static PyObject *__pyx_n_s_get_position_list;
static PyObject *__pyx_n_s_get_rgb255;
static PyObject *__pyx_n_s_get_segmentchain_coordinate;
static PyObject *__pyx_kp_s_get_segmentchain_coordinate_quer;
static PyObject *__pyx_kp_s_get_segmentchain_coordinate_quer_2;
static PyObject *__pyx_n_s_get_sequence;
static PyObject *__pyx_n_s_get_str_from_rgb;
static PyObject *__pyx_n_s_get_str_from_rgb255;
static PyObject *__pyx_n_s_get_subchain;
static PyObject *__pyx_n_s_get_utr3;
static PyObject *__pyx_n_s_get_utr5;
static PyObject *__pyx_n_s_getitem;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
static PyObject *__pyx_n_s_groups;
static PyObject *__pyx_kp_s_homeroot_joshua_projects_plasti;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_igvpat;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_inp;
static PyObject *__pyx_n_s_int;
static PyObject *__pyx_n_s_intc;
static PyObject *__pyx_n_s_isnan;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_itemsize;
static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
static PyObject *__pyx_n_s_iv;
static PyObject *__pyx_n_s_iv_ltmp;
static PyObject *__pyx_n_s_ivcpat;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_n_s_key;
static PyObject *__pyx_n_s_l;
static PyObject *__pyx_n_s_line;
static PyObject *__pyx_n_s_loc_str;
static PyObject *__pyx_n_s_long;
static PyObject *__pyx_n_s_ltmp;
static PyObject *__pyx_n_s_mRNA;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_make_GFF3_tokens;
static PyObject *__pyx_n_s_make_GTF2_tokens;
static PyObject *__pyx_n_s_mask;
static PyObject *__pyx_n_s_match_length;
static PyObject *__pyx_n_s_memview;
static PyObject *__pyx_n_s_middle;
static PyObject *__pyx_n_s_mismatches;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_na;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_kp_s_name_s;
static PyObject *__pyx_n_s_nan;
static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
static PyObject *__pyx_n_s_ndim;
static PyObject *__pyx_n_s_next;
static PyObject *__pyx_n_s_none;
static PyObject *__pyx_n_s_num_bed_columns;
static PyObject *__pyx_n_s_num_extra_columns;
static PyObject *__pyx_n_s_num_frags;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_numpy_ma;
static PyObject *__pyx_n_s_obj;
static PyObject *__pyx_n_s_other;
static PyObject *__pyx_n_s_overlaps;
static PyObject *__pyx_n_s_pack;
static PyObject *__pyx_n_s_phase;
static PyObject *__pyx_n_s_piece;
static PyObject *__pyx_n_s_plastid_genomics_roitools;
static PyObject *__pyx_n_s_plastid_plotting_colors;
static PyObject *__pyx_n_s_plastid_readers_gff_tokens;
static PyObject *__pyx_n_s_plastid_util_services_decorators;
static PyObject *__pyx_n_s_plastid_util_services_exceptions;
static PyObject *__pyx_n_s_pop;
static PyObject *__pyx_n_s_positions;
static PyObject *__pyx_n_s_psl_line;
static PyObject *__pyx_n_s_pyx_capi;
static PyObject *__pyx_n_s_pyx_getbuffer;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_q_starts;
static PyObject *__pyx_n_s_query_end;
static PyObject *__pyx_n_s_query_gap_bases;
static PyObject *__pyx_n_s_query_gap_count;
static PyObject *__pyx_n_s_query_length;
static PyObject *__pyx_n_s_query_name;
static PyObject *__pyx_n_s_query_start;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_re;
static PyObject *__pyx_n_s_rep_matches;
static PyObject *__pyx_n_s_reverse_complement;
static PyObject *__pyx_n_s_rna_type;
static PyObject *__pyx_n_s_roi_order;
static PyObject *__pyx_n_s_round;
static PyObject *__pyx_kp_s_s_3UTR;
static PyObject *__pyx_kp_s_s_5UTR;
static PyObject *__pyx_n_s_s_end;
static PyObject *__pyx_kp_s_s_exon_s;
static PyObject *__pyx_kp_s_s_get_length_is_deprecated_and;
static PyObject *__pyx_kp_s_s_get_masked_length_is_deprecat;
static PyObject *__pyx_kp_s_s_is_a_zero_length_SegmentChain;
static PyObject *__pyx_kp_s_s_is_a_zero_length_SegmentChain_2;
static PyObject *__pyx_kp_s_s_s;
static PyObject *__pyx_kp_s_s_s_2;
static PyObject *__pyx_kp_s_s_s_3;
static PyObject *__pyx_kp_s_s_s_s;
static PyObject *__pyx_kp_s_s_s_s_2;
static PyObject *__pyx_kp_s_s_s_s_3;
static PyObject *__pyx_kp_s_s_s_s_4;
static PyObject *__pyx_kp_s_s_s_s_s;
static PyObject *__pyx_kp_s_s_s_s_s_strand_s;
static PyObject *__pyx_kp_s_s_segments_s;
static PyObject *__pyx_n_s_s_start;
static PyObject *__pyx_kp_s_s_subchain;
static PyObject *__pyx_kp_s_s_value_of_s_cannot_be_None;
static PyObject *__pyx_n_s_score;
static PyObject *__pyx_n_s_search;
static PyObject *__pyx_n_s_seg;
static PyObject *__pyx_n_s_segchain;
static PyObject *__pyx_n_s_segment;
static PyObject *__pyx_n_s_segments;
static PyObject *__pyx_n_s_segpat;
static PyObject *__pyx_n_s_segs;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_seq;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_source;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_sstart;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_start_codon;
static PyObject *__pyx_kp_s_start_coordinate_supplied_is_Non;
static PyObject *__pyx_n_s_staticmethod;
static PyObject *__pyx_n_s_step;
static PyObject *__pyx_n_s_stmp;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_n_s_stop_codon;
static PyObject *__pyx_n_s_strand;
static PyObject *__pyx_kp_s_strand_to_str_Strand_must_be_for;
static PyObject *__pyx_kp_s_strand_undefined;
static PyObject *__pyx_n_s_stranded;
static PyObject *__pyx_kp_s_strided_and_direct;
static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
static PyObject *__pyx_kp_s_strided_and_indirect;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_s_struct;
static PyObject *__pyx_n_s_sum;
static PyObject *__pyx_n_s_t_start;
static PyObject *__pyx_n_s_t_starts;
static PyObject *__pyx_n_s_target_end;
static PyObject *__pyx_n_s_target_gap_bases;
static PyObject *__pyx_n_s_target_gap_count;
static PyObject *__pyx_n_s_target_length;
static PyObject *__pyx_n_s_target_name;
static PyObject *__pyx_n_s_target_start;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_thickend;
static PyObject *__pyx_n_s_thickstart;
static PyObject *__pyx_n_s_three_prime_UTR;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_tolist;
static PyObject *__pyx_n_s_transcript;
static PyObject *__pyx_n_s_transcript_id;
static PyObject *__pyx_n_s_tup;
static PyObject *__pyx_n_s_tx;
static PyObject *__pyx_n_s_type;
static PyObject *__pyx_n_s_types;
static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
static PyObject *__pyx_n_s_unpack;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_v;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_warn;
static PyObject *__pyx_n_s_warnings;
static PyObject *__pyx_kp_s_wrong_and_or_multiple_chromosom;
static PyObject *__pyx_kp_s_wrong_and_or_multiple_strands;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_7plastid_8genomics_8roitools__get_attr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtmp); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_2_format_segmentchain(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_segchain); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_4_format_transcript(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_tx); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_6positions_to_segments(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_strand, PyObject *__pyx_v_positions); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_8positionlist_to_segments(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_strand, PyObject *__pyx_v_positions); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10add_three_for_stop_codon(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_tx); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment___cinit__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, PyObject *__pyx_v_chrom, long __pyx_v_start, long __pyx_v_end, PyObject *__pyx_v_strand); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_2__reduce__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_4__repr__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_6__str__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_8from_str(PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_10__copy__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_12__deepcopy__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo); /* proto */
static Py_ssize_t __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_14__len__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_16__richcmp__(PyObject *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_v_cmptype); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_18_cmp_helper(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_v_cmptype); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_22contains(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_24overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_26as_igv_str(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_28from_igv_str(PyObject *__pyx_v_loc_str, PyObject *__pyx_v_strand); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_5start___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_3end___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_5chrom___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_6strand___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_8c_strand___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain___cinit__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_attr); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_2sort(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_5chrom___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6strand___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8c_strand___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8segments___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_13mask_segments___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4__reduce__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6__getstate__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8__setstate__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_10__copy__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_12__deepcopy__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_14__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmpval); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_16__repr__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_18__str__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_22__iter__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_24__next__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_26next(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_28__len__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_30__contains__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_32shares_segments_with(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_34unstranded_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_36overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_38antisense_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_40covers(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_42get_antisense(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_44get_position_list(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_46get_position_set(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_48get_masked_position_set(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_50get_name(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_52get_gene(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_54get_length(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_56get_masked_length(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_58add_segments(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_60add_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_mask_segments); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_62get_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_64get_masks_as_segmentchain(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_66reset_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_68get_junctions(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_70as_gff3(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_feature_type, CYTHON_UNUSED int __pyx_v_escape, PyObject *__pyx_v_excludes); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_72as_gtf(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_feature_type, int __pyx_v_escape, PyObject *__pyx_v_excludes); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_74_get_8_gff_columns(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_segment, PyObject *__pyx_v_feature_type); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_3genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_6genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_9genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_76as_bed(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_thickstart, PyObject *__pyx_v_thickend, PyObject *__pyx_v_as_int, PyObject *__pyx_v_color, PyObject *__pyx_v_extra_columns); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_psl_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_78as_psl(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_80get_segmentchain_coordinate(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_chrom, long __pyx_v_genomic_x, PyObject *__pyx_v_strand, int __pyx_v_stranded); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_82get_genomic_coordinate(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_stranded); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_84get_subchain(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, long __pyx_v_start, long __pyx_v_end, int __pyx_v_stranded, PyObject *__pyx_v_extra_attr); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_86get_counts(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_ga, PyObject *__pyx_v_stranded); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_88get_masked_counts(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_ga, CYTHON_UNUSED PyObject *__pyx_v_stranded, PyObject *__pyx_v_copy); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_90get_sequence(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_genome, PyObject *__pyx_v_stranded); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_92get_fasta(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_genome, PyObject *__pyx_v_stranded); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_94from_str(PyObject *__pyx_v_inp); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_96from_bed(PyObject *__pyx_v_line, PyObject *__pyx_v_extra_columns); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_98from_psl(PyObject *__pyx_v_psl_line); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_16spanning_segment___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6length___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_13masked_length___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr_4__del__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript___cinit__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_type, CYTHON_UNUSED PyObject *__pyx_v_segments, PyObject *__pyx_v_attr); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_2__copy__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_4__deepcopy__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_6__reduce__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_8__getstate__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_10__setstate__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_state); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_12__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmpval); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_9cds_start___get__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript_9cds_start_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_7cds_end___get__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript_7cds_end_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start___get__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end___get__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto */
static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_14get_name(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_16get_cds(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_extra_attr); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_18get_utr5(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_extra_attr); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_20get_utr3(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_extra_attr); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_22as_gtf(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_feature_type, int __pyx_v_escape, PyObject *__pyx_v_excludes); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_24as_gff3(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, int __pyx_v_escape, PyObject *__pyx_v_excludes, PyObject *__pyx_v_rna_type); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_26as_bed(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_as_int, PyObject *__pyx_v_color, PyObject *__pyx_v_extra_columns); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_28from_bed(PyObject *__pyx_v_line, PyObject *__pyx_v_extra_columns); /* proto */
static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_30from_psl(PyObject *__pyx_v_psl_line); /* proto */
static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags); /* proto */
static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info); /* 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 int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */
static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */
static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */
static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools_GenomicSegment(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools_SegmentChain(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools_Transcript(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, &__pyx_n_s_items, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values = {0, &__pyx_n_s_values, 0, 0, 0};
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_6;
static PyObject *__pyx_int_7;
static PyObject *__pyx_int_8;
static PyObject *__pyx_int_9;
static PyObject *__pyx_int_10;
static PyObject *__pyx_int_11;
static PyObject *__pyx_int_255;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_k__15;
static PyObject *__pyx_k__19;
static PyObject *__pyx_k__46;
static PyObject *__pyx_k__49;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_slice__23;
static PyObject *__pyx_slice__24;
static PyObject *__pyx_slice__68;
static PyObject *__pyx_slice__69;
static PyObject *__pyx_slice__70;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__98;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_tuple__100;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_codeobj__78;
static PyObject *__pyx_codeobj__80;
static PyObject *__pyx_codeobj__82;
static PyObject *__pyx_codeobj__84;
static PyObject *__pyx_codeobj__86;
static PyObject *__pyx_codeobj__88;
static PyObject *__pyx_codeobj__90;
static PyObject *__pyx_codeobj__92;
static PyObject *__pyx_codeobj__94;
static PyObject *__pyx_codeobj__96;

/* "plastid/genomics/roitools.pyx":151
 * #===============================================================================
 * 
 * def _get_attr(dict dtmp):             # <<<<<<<<<<<<<<
 *     ltmp=[]
 *     for k,v in sorted(dtmp.items()):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_1_get_attr(PyObject *__pyx_self, PyObject *__pyx_v_dtmp); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools__get_attr[] = "_get_attr(dict dtmp)";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_1_get_attr = {"_get_attr", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_1_get_attr, METH_O, __pyx_doc_7plastid_8genomics_8roitools__get_attr};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_1_get_attr(PyObject *__pyx_self, PyObject *__pyx_v_dtmp) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_attr (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dtmp), (&PyDict_Type), 1, "dtmp", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools__get_attr(__pyx_self, ((PyObject*)__pyx_v_dtmp));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools__get_attr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dtmp) {
  PyObject *__pyx_v_ltmp = 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;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  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("_get_attr", 0);

  /* "plastid/genomics/roitools.pyx":152
 * 
 * def _get_attr(dict dtmp):
 *     ltmp=[]             # <<<<<<<<<<<<<<
 *     for k,v in sorted(dtmp.items()):
 *         ltmp.append("%s='%s'" % (k,v))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ltmp = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":153
 * def _get_attr(dict dtmp):
 *     ltmp=[]
 *     for k,v in sorted(dtmp.items()):             # <<<<<<<<<<<<<<
 *         ltmp.append("%s='%s'" % (k,v))
 * 
 */
  if (unlikely(__pyx_v_dtmp == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "items");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_dtmp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PySequence_List(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_4 = PyList_Sort(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    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 = 153; __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 = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    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 = 153; __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 = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #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 = 153; __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 = 153; __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 = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":154
 *     ltmp=[]
 *     for k,v in sorted(dtmp.items()):
 *         ltmp.append("%s='%s'" % (k,v))             # <<<<<<<<<<<<<<
 * 
 *     return ",".join(ltmp)
 */
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_k);
    __Pyx_GIVEREF(__pyx_v_k);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_k);
    __Pyx_INCREF(__pyx_v_v);
    __Pyx_GIVEREF(__pyx_v_v);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_v);
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_ltmp, __pyx_t_6); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":153
 * def _get_attr(dict dtmp):
 *     ltmp=[]
 *     for k,v in sorted(dtmp.items()):             # <<<<<<<<<<<<<<
 *         ltmp.append("%s='%s'" % (k,v))
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "plastid/genomics/roitools.pyx":156
 *         ltmp.append("%s='%s'" % (k,v))
 * 
 *     return ",".join(ltmp)             # <<<<<<<<<<<<<<
 * 
 * def _format_segmentchain(SegmentChain segchain):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_v_ltmp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":151
 * #===============================================================================
 * 
 * def _get_attr(dict dtmp):             # <<<<<<<<<<<<<<
 *     ltmp=[]
 *     for k,v in sorted(dtmp.items()):
 */

  /* function exit code */
  __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("plastid.genomics.roitools._get_attr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ltmp);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":158
 *     return ",".join(ltmp)
 * 
 * def _format_segmentchain(SegmentChain segchain):             # <<<<<<<<<<<<<<
 *     """Formats a |SegmentChain| as a string, which when ``eval`` ed, should reconstruct the |SegmentChain|.
 *     Used for creating test datasets.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_3_format_segmentchain(PyObject *__pyx_self, PyObject *__pyx_v_segchain); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_2_format_segmentchain[] = "_format_segmentchain(SegmentChain segchain)\nFormats a |SegmentChain| as a string, which when ``eval`` ed, should reconstruct the |SegmentChain|.\n    Used for creating test datasets.\n    \n    Parameters\n    ----------\n    segchain : |SegmentChain|\n    \n    Returns\n    -------\n    str\n    ";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_3_format_segmentchain = {"_format_segmentchain", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_3_format_segmentchain, METH_O, __pyx_doc_7plastid_8genomics_8roitools_2_format_segmentchain};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_3_format_segmentchain(PyObject *__pyx_self, PyObject *__pyx_v_segchain) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_format_segmentchain (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segchain), __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain, 1, "segchain", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_2_format_segmentchain(__pyx_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_segchain));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_2_format_segmentchain(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_segchain) {
  PyObject *__pyx_v_iv_ltmp = NULL;
  PyObject *__pyx_v_iv = NULL;
  PyObject *__pyx_v_stmp = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  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_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_format_segmentchain", 0);

  /* "plastid/genomics/roitools.pyx":170
 *     str
 *     """
 *     iv_ltmp = []             # <<<<<<<<<<<<<<
 *     for iv in segchain:
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_iv_ltmp = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":171
 *     """
 *     iv_ltmp = []
 *     for iv in segchain:             # <<<<<<<<<<<<<<
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_segchain))) || PyTuple_CheckExact(((PyObject *)__pyx_v_segchain))) {
    __pyx_t_1 = ((PyObject *)__pyx_v_segchain); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_segchain)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_iv, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "plastid/genomics/roitools.pyx":172
 *     iv_ltmp = []
 *     for iv in segchain:
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))             # <<<<<<<<<<<<<<
 * 
 *     stmp = "SegmentChain(%s,%s)" % (",".join(iv_ltmp),
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_iv, __pyx_n_s_chrom); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_iv, __pyx_n_s_start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_iv, __pyx_n_s_end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_iv, __pyx_n_s_strand); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_GenomicSegment_s_s_s_s, __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_iv_ltmp, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "plastid/genomics/roitools.pyx":171
 *     """
 *     iv_ltmp = []
 *     for iv in segchain:             # <<<<<<<<<<<<<<
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":174
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 * 
 *     stmp = "SegmentChain(%s,%s)" % (",".join(iv_ltmp),             # <<<<<<<<<<<<<<
 *                                     _get_attr(segchain.attr)
 *                                                           )
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_v_iv_ltmp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":175
 * 
 *     stmp = "SegmentChain(%s,%s)" % (",".join(iv_ltmp),
 *                                     _get_attr(segchain.attr)             # <<<<<<<<<<<<<<
 *                                                           )
 *     return stmp
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_attr); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_segchain->attr); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_segchain->attr);
    __Pyx_GIVEREF(__pyx_v_segchain->attr);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_segchain->attr);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "plastid/genomics/roitools.pyx":174
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 * 
 *     stmp = "SegmentChain(%s,%s)" % (",".join(iv_ltmp),             # <<<<<<<<<<<<<<
 *                                     _get_attr(segchain.attr)
 *                                                           )
 */
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_s_s, __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_stmp = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "plastid/genomics/roitools.pyx":177
 *                                     _get_attr(segchain.attr)
 *                                                           )
 *     return stmp             # <<<<<<<<<<<<<<
 * 
 * def _format_transcript(Transcript tx):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_stmp);
  __pyx_r = __pyx_v_stmp;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":158
 *     return ",".join(ltmp)
 * 
 * def _format_segmentchain(SegmentChain segchain):             # <<<<<<<<<<<<<<
 *     """Formats a |SegmentChain| as a string, which when ``eval`` ed, should reconstruct the |SegmentChain|.
 *     Used for creating test datasets.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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("plastid.genomics.roitools._format_segmentchain", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_iv_ltmp);
  __Pyx_XDECREF(__pyx_v_iv);
  __Pyx_XDECREF(__pyx_v_stmp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":179
 *     return stmp
 * 
 * def _format_transcript(Transcript tx):             # <<<<<<<<<<<<<<
 *     """Formats a |Transcript| as a string, which when ``eval`` ed, should reconstruct the |Transcript|.
 *     Used for creating test datasets.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_5_format_transcript(PyObject *__pyx_self, PyObject *__pyx_v_tx); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_4_format_transcript[] = "_format_transcript(Transcript tx)\nFormats a |Transcript| as a string, which when ``eval`` ed, should reconstruct the |Transcript|.\n    Used for creating test datasets.\n    \n    Parameters\n    ----------\n    tx : |Transcript|\n    \n    Returns\n    -------\n    str\n    ";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_5_format_transcript = {"_format_transcript", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_5_format_transcript, METH_O, __pyx_doc_7plastid_8genomics_8roitools_4_format_transcript};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_5_format_transcript(PyObject *__pyx_self, PyObject *__pyx_v_tx) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_format_transcript (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tx), __pyx_ptype_7plastid_8genomics_8roitools_Transcript, 1, "tx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_4_format_transcript(__pyx_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_tx));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_4_format_transcript(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_tx) {
  PyObject *__pyx_v_iv_ltmp = NULL;
  PyObject *__pyx_v_iv = NULL;
  PyObject *__pyx_v_stmp = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  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_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_format_transcript", 0);

  /* "plastid/genomics/roitools.pyx":191
 *     str
 *     """
 *     iv_ltmp = []             # <<<<<<<<<<<<<<
 *     for iv in tx:
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_iv_ltmp = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":192
 *     """
 *     iv_ltmp = []
 *     for iv in tx:             # <<<<<<<<<<<<<<
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 * 
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_tx))) || PyTuple_CheckExact(((PyObject *)__pyx_v_tx))) {
    __pyx_t_1 = ((PyObject *)__pyx_v_tx); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_tx)); 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_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_iv, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "plastid/genomics/roitools.pyx":193
 *     iv_ltmp = []
 *     for iv in tx:
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))             # <<<<<<<<<<<<<<
 * 
 *     stmp = "Transcript(%s,ID='%s',cds_genome_start=%s,cds_genome_end=%s)" % (",".join(iv_ltmp),
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_iv, __pyx_n_s_chrom); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_iv, __pyx_n_s_start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_iv, __pyx_n_s_end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_iv, __pyx_n_s_strand); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_GenomicSegment_s_s_s_s, __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_iv_ltmp, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "plastid/genomics/roitools.pyx":192
 *     """
 *     iv_ltmp = []
 *     for iv in tx:             # <<<<<<<<<<<<<<
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":195
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 * 
 *     stmp = "Transcript(%s,ID='%s',cds_genome_start=%s,cds_genome_end=%s)" % (",".join(iv_ltmp),             # <<<<<<<<<<<<<<
 *                                                           tx.get_name(),
 *                                                           tx.attr["cds_genome_start"],
 */
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_v_iv_ltmp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":196
 * 
 *     stmp = "Transcript(%s,ID='%s',cds_genome_start=%s,cds_genome_end=%s)" % (",".join(iv_ltmp),
 *                                                           tx.get_name(),             # <<<<<<<<<<<<<<
 *                                                           tx.attr["cds_genome_start"],
 *                                                           tx.attr["cds_genome_end"]
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tx), __pyx_n_s_get_name); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "plastid/genomics/roitools.pyx":197
 *     stmp = "Transcript(%s,ID='%s',cds_genome_start=%s,cds_genome_end=%s)" % (",".join(iv_ltmp),
 *                                                           tx.get_name(),
 *                                                           tx.attr["cds_genome_start"],             # <<<<<<<<<<<<<<
 *                                                           tx.attr["cds_genome_end"]
 *                                                           )
 */
  if (unlikely(__pyx_v_tx->__pyx_base.attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_tx->__pyx_base.attr, __pyx_n_s_cds_genome_start); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_8);

  /* "plastid/genomics/roitools.pyx":198
 *                                                           tx.get_name(),
 *                                                           tx.attr["cds_genome_start"],
 *                                                           tx.attr["cds_genome_end"]             # <<<<<<<<<<<<<<
 *                                                           )
 *     return stmp
 */
  if (unlikely(__pyx_v_tx->__pyx_base.attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_tx->__pyx_base.attr, __pyx_n_s_cds_genome_end); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_6);

  /* "plastid/genomics/roitools.pyx":195
 *         iv_ltmp.append("GenomicSegment('%s',%s,%s,'%s')" % (iv.chrom,iv.start,iv.end,iv.strand))
 * 
 *     stmp = "Transcript(%s,ID='%s',cds_genome_start=%s,cds_genome_end=%s)" % (",".join(iv_ltmp),             # <<<<<<<<<<<<<<
 *                                                           tx.get_name(),
 *                                                           tx.attr["cds_genome_start"],
 */
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Transcript_s_ID_s_cds_genome_sta, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_stmp = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "plastid/genomics/roitools.pyx":200
 *                                                           tx.attr["cds_genome_end"]
 *                                                           )
 *     return stmp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_stmp);
  __pyx_r = __pyx_v_stmp;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":179
 *     return stmp
 * 
 * def _format_transcript(Transcript tx):             # <<<<<<<<<<<<<<
 *     """Formats a |Transcript| as a string, which when ``eval`` ed, should reconstruct the |Transcript|.
 *     Used for creating test datasets.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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("plastid.genomics.roitools._format_transcript", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_iv_ltmp);
  __Pyx_XDECREF(__pyx_v_iv);
  __Pyx_XDECREF(__pyx_v_stmp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":207
 * #==============================================================================
 * 
 * cpdef list positions_to_segments(str chrom, str strand, object positions):             # <<<<<<<<<<<<<<
 *     """Construct |GenomicSegments| from a chromosome name, a strand, and a list of chromosomal positions
 * 
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_7positions_to_segments(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_positions_to_segments(PyObject *__pyx_v_chrom, PyObject *__pyx_v_strand, PyObject *__pyx_v_positions, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("positions_to_segments", 0);
  __Pyx_INCREF(__pyx_v_positions);

  /* "plastid/genomics/roitools.pyx":227
 *         List of |GenomicSegments| covering `positions`
 *     """
 *     if isinstance(positions,set):             # <<<<<<<<<<<<<<
 *         positions = sorted(positions)
 *     else:
 */
  __pyx_t_1 = PySet_Check(__pyx_v_positions); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":228
 *     """
 *     if isinstance(positions,set):
 *         positions = sorted(positions)             # <<<<<<<<<<<<<<
 *     else:
 *         positions = sorted(set(positions))
 */
    __pyx_t_4 = PySequence_List(__pyx_v_positions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_5 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF_SET(__pyx_v_positions, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":227
 *         List of |GenomicSegments| covering `positions`
 *     """
 *     if isinstance(positions,set):             # <<<<<<<<<<<<<<
 *         positions = sorted(positions)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":230
 *         positions = sorted(positions)
 *     else:
 *         positions = sorted(set(positions))             # <<<<<<<<<<<<<<
 *     return positionlist_to_segments(chrom,strand,positions)
 * 
 */
  /*else*/ {
    __pyx_t_4 = PySet_New(__pyx_v_positions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_5 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF_SET(__pyx_v_positions, __pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":231
 *     else:
 *         positions = sorted(set(positions))
 *     return positionlist_to_segments(chrom,strand,positions)             # <<<<<<<<<<<<<<
 * 
 * cpdef list positionlist_to_segments(str chrom, str strand, list positions):
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyList_CheckExact(__pyx_v_positions))||((__pyx_v_positions) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_positions)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments(__pyx_v_chrom, __pyx_v_strand, ((PyObject*)__pyx_v_positions), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":207
 * #==============================================================================
 * 
 * cpdef list positions_to_segments(str chrom, str strand, object positions):             # <<<<<<<<<<<<<<
 *     """Construct |GenomicSegments| from a chromosome name, a strand, and a list of chromosomal positions
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.positions_to_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_positions);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_7positions_to_segments(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_6positions_to_segments[] = "positions_to_segments(str chrom, str strand, positions) -> list\nConstruct |GenomicSegments| from a chromosome name, a strand, and a list of chromosomal positions\n\n    Parameters\n    ----------\n    chrom : str\n        Chromosome name\n       \n    strand : str\n        Chromosome strand (`'+'`, `'-'`, or `'.'`)\n       \n    positions : list of integers\n        **End-inclusive** list, tuple, or set of positions to include\n        in final |GenomicSegment|\n           \n    Returns\n    -------\n    list\n        List of |GenomicSegments| covering `positions`\n    ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_7positions_to_segments(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_strand = 0;
  PyObject *__pyx_v_positions = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("positions_to_segments (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_chrom,&__pyx_n_s_strand,&__pyx_n_s_positions,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_chrom)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_strand)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("positions_to_segments", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("positions_to_segments", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "positions_to_segments") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __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_chrom = ((PyObject*)values[0]);
    __pyx_v_strand = ((PyObject*)values[1]);
    __pyx_v_positions = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("positions_to_segments", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.positions_to_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chrom), (&PyString_Type), 1, "chrom", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_strand), (&PyString_Type), 1, "strand", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_6positions_to_segments(__pyx_self, __pyx_v_chrom, __pyx_v_strand, __pyx_v_positions);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_6positions_to_segments(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_strand, PyObject *__pyx_v_positions) {
  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("positions_to_segments", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7plastid_8genomics_8roitools_positions_to_segments(__pyx_v_chrom, __pyx_v_strand, __pyx_v_positions, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.positions_to_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":233
 *     return positionlist_to_segments(chrom,strand,positions)
 * 
 * cpdef list positionlist_to_segments(str chrom, str strand, list positions):             # <<<<<<<<<<<<<<
 *     """Construct |GenomicSegments| from a chromosome name, a strand, and a list of chromosomal positions
 * 
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_9positionlist_to_segments(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments(PyObject *__pyx_v_chrom, PyObject *__pyx_v_strand, PyObject *__pyx_v_positions, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_segments = 0;
  long __pyx_v_start;
  long __pyx_v_last_pos;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("positionlist_to_segments", 0);

  /* "plastid/genomics/roitools.pyx":261
 *     """
 *     cdef:
 *         list segments = []             # <<<<<<<<<<<<<<
 *         long start, last_pos, i
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_segments = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":264
 *         long start, last_pos, i
 * 
 *     if len(positions) > 0:             # <<<<<<<<<<<<<<
 *         start = positions[0]
 *         last_pos = positions[0]
 */
  if (unlikely(__pyx_v_positions == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_v_positions); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((__pyx_t_2 > 0) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":265
 * 
 *     if len(positions) > 0:
 *         start = positions[0]             # <<<<<<<<<<<<<<
 *         last_pos = positions[0]
 *         for i in positions:
 */
    if (unlikely(__pyx_v_positions == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_positions, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_start = __pyx_t_4;

    /* "plastid/genomics/roitools.pyx":266
 *     if len(positions) > 0:
 *         start = positions[0]
 *         last_pos = positions[0]             # <<<<<<<<<<<<<<
 *         for i in positions:
 *             if i == start:
 */
    if (unlikely(__pyx_v_positions == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_positions, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_last_pos = __pyx_t_4;

    /* "plastid/genomics/roitools.pyx":267
 *         start = positions[0]
 *         last_pos = positions[0]
 *         for i in positions:             # <<<<<<<<<<<<<<
 *             if i == start:
 *                 continue
 */
    if (unlikely(__pyx_v_positions == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __pyx_v_positions; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    for (;;) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_5); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_i = __pyx_t_4;

      /* "plastid/genomics/roitools.pyx":268
 *         last_pos = positions[0]
 *         for i in positions:
 *             if i == start:             # <<<<<<<<<<<<<<
 *                 continue
 *             if i - last_pos == 1:
 */
      __pyx_t_3 = ((__pyx_v_i == __pyx_v_start) != 0);
      if (__pyx_t_3) {

        /* "plastid/genomics/roitools.pyx":269
 *         for i in positions:
 *             if i == start:
 *                 continue             # <<<<<<<<<<<<<<
 *             if i - last_pos == 1:
 *                 last_pos = i
 */
        goto __pyx_L4_continue;

        /* "plastid/genomics/roitools.pyx":268
 *         last_pos = positions[0]
 *         for i in positions:
 *             if i == start:             # <<<<<<<<<<<<<<
 *                 continue
 *             if i - last_pos == 1:
 */
      }

      /* "plastid/genomics/roitools.pyx":270
 *             if i == start:
 *                 continue
 *             if i - last_pos == 1:             # <<<<<<<<<<<<<<
 *                 last_pos = i
 *             else:
 */
      __pyx_t_3 = (((__pyx_v_i - __pyx_v_last_pos) == 1) != 0);
      if (__pyx_t_3) {

        /* "plastid/genomics/roitools.pyx":271
 *                 continue
 *             if i - last_pos == 1:
 *                 last_pos = i             # <<<<<<<<<<<<<<
 *             else:
 *                 segments.append(GenomicSegment(chrom,start,last_pos+1,strand))
 */
        __pyx_v_last_pos = __pyx_v_i;

        /* "plastid/genomics/roitools.pyx":270
 *             if i == start:
 *                 continue
 *             if i - last_pos == 1:             # <<<<<<<<<<<<<<
 *                 last_pos = i
 *             else:
 */
        goto __pyx_L7;
      }

      /* "plastid/genomics/roitools.pyx":273
 *                 last_pos = i
 *             else:
 *                 segments.append(GenomicSegment(chrom,start,last_pos+1,strand))             # <<<<<<<<<<<<<<
 *                 start = i
 *                 last_pos = i
 */
      /*else*/ {
        __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_last_pos + 1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
        __Pyx_INCREF(__pyx_v_strand);
        __Pyx_GIVEREF(__pyx_v_strand);
        PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v_strand);
        __pyx_t_5 = 0;
        __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_segments, __pyx_t_6); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "plastid/genomics/roitools.pyx":274
 *             else:
 *                 segments.append(GenomicSegment(chrom,start,last_pos+1,strand))
 *                 start = i             # <<<<<<<<<<<<<<
 *                 last_pos = i
 *         segments.append(GenomicSegment(chrom,start,last_pos+1,strand))
 */
        __pyx_v_start = __pyx_v_i;

        /* "plastid/genomics/roitools.pyx":275
 *                 segments.append(GenomicSegment(chrom,start,last_pos+1,strand))
 *                 start = i
 *                 last_pos = i             # <<<<<<<<<<<<<<
 *         segments.append(GenomicSegment(chrom,start,last_pos+1,strand))
 * 
 */
        __pyx_v_last_pos = __pyx_v_i;
      }
      __pyx_L7:;

      /* "plastid/genomics/roitools.pyx":267
 *         start = positions[0]
 *         last_pos = positions[0]
 *         for i in positions:             # <<<<<<<<<<<<<<
 *             if i == start:
 *                 continue
 */
      __pyx_L4_continue:;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":276
 *                 start = i
 *                 last_pos = i
 *         segments.append(GenomicSegment(chrom,start,last_pos+1,strand))             # <<<<<<<<<<<<<<
 * 
 *     return segments
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_last_pos + 1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_strand);
    __Pyx_GIVEREF(__pyx_v_strand);
    PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v_strand);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_segments, __pyx_t_6); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":264
 *         long start, last_pos, i
 * 
 *     if len(positions) > 0:             # <<<<<<<<<<<<<<
 *         start = positions[0]
 *         last_pos = positions[0]
 */
  }

  /* "plastid/genomics/roitools.pyx":278
 *         segments.append(GenomicSegment(chrom,start,last_pos+1,strand))
 * 
 *     return segments             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_segments);
  __pyx_r = __pyx_v_segments;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":233
 *     return positionlist_to_segments(chrom,strand,positions)
 * 
 * cpdef list positionlist_to_segments(str chrom, str strand, list positions):             # <<<<<<<<<<<<<<
 *     """Construct |GenomicSegments| from a chromosome name, a strand, and a list of chromosomal positions
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("plastid.genomics.roitools.positionlist_to_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_segments);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_9positionlist_to_segments(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_8positionlist_to_segments[] = "positionlist_to_segments(str chrom, str strand, list positions) -> list\nConstruct |GenomicSegments| from a chromosome name, a strand, and a list of chromosomal positions\n\n    Parameters\n    ----------\n    chrom : str\n        Chromosome name\n       \n    strand : str\n        Chromosome strand (`'+'`, `'-'`, or `'.'`)\n       \n    positions : list of unique integers\n        Sorted, **end-inclusive** list of positions to include\n        in final |GenomicSegment|\n           \n    Returns\n    -------\n    list\n        List of |GenomicSegments| covering `positions`\n\n\n     .. warning::\n        \n        This function is meant to quickly without excessive type conversions.\n        So, the elements `positions` must be **UNIQUE** and **SORTED**. If\n        they are not, use :func:`positions_to_segments` instead.\n    ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_9positionlist_to_segments(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_strand = 0;
  PyObject *__pyx_v_positions = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("positionlist_to_segments (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_chrom,&__pyx_n_s_strand,&__pyx_n_s_positions,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_chrom)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_strand)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("positionlist_to_segments", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("positionlist_to_segments", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "positionlist_to_segments") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __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_chrom = ((PyObject*)values[0]);
    __pyx_v_strand = ((PyObject*)values[1]);
    __pyx_v_positions = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("positionlist_to_segments", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.positionlist_to_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chrom), (&PyString_Type), 1, "chrom", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_strand), (&PyString_Type), 1, "strand", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_positions), (&PyList_Type), 1, "positions", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_8positionlist_to_segments(__pyx_self, __pyx_v_chrom, __pyx_v_strand, __pyx_v_positions);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_8positionlist_to_segments(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_strand, PyObject *__pyx_v_positions) {
  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("positionlist_to_segments", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments(__pyx_v_chrom, __pyx_v_strand, __pyx_v_positions, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.positionlist_to_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":281
 * 
 * 
 * cpdef Transcript add_three_for_stop_codon(Transcript tx):             # <<<<<<<<<<<<<<
 *     """Extend an annotated CDS region, if present, by three nucleotides
 *     at the threeprime end. Use in cases when annotation files exclude the stop
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_11add_three_for_stop_codon(PyObject *__pyx_self, PyObject *__pyx_v_tx); /*proto*/
static struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_f_7plastid_8genomics_8roitools_add_three_for_stop_codon(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_tx, CYTHON_UNUSED int __pyx_skip_dispatch) {
  long __pyx_v_start;
  long __pyx_v_end;
  long __pyx_v_new_start;
  long __pyx_v_new_end;
  int __pyx_v_n;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_span = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_new_seg = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_old_seg = 0;
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_attr = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_new_tx = 0;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_segment = NULL;
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  long __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  long __pyx_t_9;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_three_for_stop_codon", 0);

  /* "plastid/genomics/roitools.pyx":309
 *         Transcript new_tx
 * 
 *     if tx.cds_genome_end is not None and tx.cds_genome_start is not None:             # <<<<<<<<<<<<<<
 *         new_start = start = <long>tx.cds_genome_start
 *         new_end = end = <long>tx.cds_genome_end
 */
  __pyx_t_2 = (__pyx_v_tx->cds_genome_end != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_tx->cds_genome_start != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":310
 * 
 *     if tx.cds_genome_end is not None and tx.cds_genome_start is not None:
 *         new_start = start = <long>tx.cds_genome_start             # <<<<<<<<<<<<<<
 *         new_end = end = <long>tx.cds_genome_end
 *         segments  = copy.copy(tx._segments)
 */
    __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_v_tx->cds_genome_start); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_new_start = ((long)__pyx_t_4);
    __pyx_v_start = ((long)__pyx_t_4);

    /* "plastid/genomics/roitools.pyx":311
 *     if tx.cds_genome_end is not None and tx.cds_genome_start is not None:
 *         new_start = start = <long>tx.cds_genome_start
 *         new_end = end = <long>tx.cds_genome_end             # <<<<<<<<<<<<<<
 *         segments  = copy.copy(tx._segments)
 *         attr = copy.deepcopy(tx.attr)
 */
    __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_v_tx->cds_genome_end); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_new_end = ((long)__pyx_t_4);
    __pyx_v_end = ((long)__pyx_t_4);

    /* "plastid/genomics/roitools.pyx":312
 *         new_start = start = <long>tx.cds_genome_start
 *         new_end = end = <long>tx.cds_genome_end
 *         segments  = copy.copy(tx._segments)             # <<<<<<<<<<<<<<
 *         attr = copy.deepcopy(tx.attr)
 *         span = tx.spanning_segment
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_copy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_tx->__pyx_base._segments); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_INCREF(__pyx_v_tx->__pyx_base._segments);
      __Pyx_GIVEREF(__pyx_v_tx->__pyx_base._segments);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_tx->__pyx_base._segments);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_segments = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":313
 *         new_end = end = <long>tx.cds_genome_end
 *         segments  = copy.copy(tx._segments)
 *         attr = copy.deepcopy(tx.attr)             # <<<<<<<<<<<<<<
 *         span = tx.spanning_segment
 *         chrom = span.chrom
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_tx->__pyx_base.attr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_tx->__pyx_base.attr);
      __Pyx_GIVEREF(__pyx_v_tx->__pyx_base.attr);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_tx->__pyx_base.attr);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __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_8); __pyx_t_8 = 0;
    if (!(likely(PyDict_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_attr = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":314
 *         segments  = copy.copy(tx._segments)
 *         attr = copy.deepcopy(tx.attr)
 *         span = tx.spanning_segment             # <<<<<<<<<<<<<<
 *         chrom = span.chrom
 *         if span.c_strand == forward_strand:
 */
    __pyx_t_5 = ((PyObject *)__pyx_v_tx->__pyx_base.spanning_segment);
    __Pyx_INCREF(__pyx_t_5);
    __pyx_v_span = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":315
 *         attr = copy.deepcopy(tx.attr)
 *         span = tx.spanning_segment
 *         chrom = span.chrom             # <<<<<<<<<<<<<<
 *         if span.c_strand == forward_strand:
 *             # if cds at end of transcript, both need to grow by three
 */
    __pyx_t_5 = __pyx_v_span->chrom;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_v_chrom = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":316
 *         span = tx.spanning_segment
 *         chrom = span.chrom
 *         if span.c_strand == forward_strand:             # <<<<<<<<<<<<<<
 *             # if cds at end of transcript, both need to grow by three
 *             if span.end == end:
 */
    __pyx_t_1 = ((__pyx_v_span->c_strand == __pyx_e_7plastid_8genomics_8c_common_forward_strand) != 0);
    if (__pyx_t_1) {

      /* "plastid/genomics/roitools.pyx":318
 *         if span.c_strand == forward_strand:
 *             # if cds at end of transcript, both need to grow by three
 *             if span.end == end:             # <<<<<<<<<<<<<<
 *                 new_end = end + 3
 *                 old_seg = segments[-1]
 */
      __pyx_t_1 = ((__pyx_v_span->end == __pyx_v_end) != 0);
      if (__pyx_t_1) {

        /* "plastid/genomics/roitools.pyx":319
 *             # if cds at end of transcript, both need to grow by three
 *             if span.end == end:
 *                 new_end = end + 3             # <<<<<<<<<<<<<<
 *                 old_seg = segments[-1]
 *                 new_seg = GenomicSegment(chrom,old_seg.start,new_end,span.strand)
 */
        __pyx_v_new_end = (__pyx_v_end + 3);

        /* "plastid/genomics/roitools.pyx":320
 *             if span.end == end:
 *                 new_end = end + 3
 *                 old_seg = segments[-1]             # <<<<<<<<<<<<<<
 *                 new_seg = GenomicSegment(chrom,old_seg.start,new_end,span.strand)
 *                 segments[-1] = new_seg
 */
        if (unlikely(__pyx_v_segments == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_segments, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_old_seg = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_5);
        __pyx_t_5 = 0;

        /* "plastid/genomics/roitools.pyx":321
 *                 new_end = end + 3
 *                 old_seg = segments[-1]
 *                 new_seg = GenomicSegment(chrom,old_seg.start,new_end,span.strand)             # <<<<<<<<<<<<<<
 *                 segments[-1] = new_seg
 *             else:
 */
        __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_old_seg->start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_new_end); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_span), __pyx_n_s_strand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_6);
        __pyx_t_5 = 0;
        __pyx_t_8 = 0;
        __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_v_new_seg = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_6);
        __pyx_t_6 = 0;

        /* "plastid/genomics/roitools.pyx":322
 *                 old_seg = segments[-1]
 *                 new_seg = GenomicSegment(chrom,old_seg.start,new_end,span.strand)
 *                 segments[-1] = new_seg             # <<<<<<<<<<<<<<
 *             else:
 *                 # if new end will be end of transcript, set manually
 */
        if (unlikely(__pyx_v_segments == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        if (unlikely(__Pyx_SetItemInt(__pyx_v_segments, -1L, ((PyObject *)__pyx_v_new_seg), long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "plastid/genomics/roitools.pyx":318
 *         if span.c_strand == forward_strand:
 *             # if cds at end of transcript, both need to grow by three
 *             if span.end == end:             # <<<<<<<<<<<<<<
 *                 new_end = end + 3
 *                 old_seg = segments[-1]
 */
        goto __pyx_L7;
      }

      /* "plastid/genomics/roitools.pyx":326
 *                 # if new end will be end of transcript, set manually
 *                 # because key won't be in position hash
 *                 if tx.cds_end + 3 == tx.length:             # <<<<<<<<<<<<<<
 *                     new_end = span.end
 *                 else:
 */
      /*else*/ {
        __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_tx->cds_end, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_tx->__pyx_base.length); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = PyObject_RichCompare(__pyx_t_6, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (__pyx_t_1) {

          /* "plastid/genomics/roitools.pyx":327
 *                 # because key won't be in position hash
 *                 if tx.cds_end + 3 == tx.length:
 *                     new_end = span.end             # <<<<<<<<<<<<<<
 *                 else:
 *                     # position is internal, so we fetch
 */
          __pyx_t_4 = __pyx_v_span->end;
          __pyx_v_new_end = __pyx_t_4;

          /* "plastid/genomics/roitools.pyx":326
 *                 # if new end will be end of transcript, set manually
 *                 # because key won't be in position hash
 *                 if tx.cds_end + 3 == tx.length:             # <<<<<<<<<<<<<<
 *                     new_end = span.end
 *                 else:
 */
          goto __pyx_L8;
        }

        /* "plastid/genomics/roitools.pyx":330
 *                 else:
 *                     # position is internal, so we fetch
 *                     new_end = tx.c_get_genomic_coordinate(tx.cds_end+3,True)             # <<<<<<<<<<<<<<
 *                     # correct for rare cases in which stop codons and at the end
 *                     # of a given exon interval, and are falsely mapped to first position
 */
        /*else*/ {
          __pyx_t_8 = __Pyx_PyInt_AddObjC(__pyx_v_tx->cds_end, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_4 = __Pyx_PyInt_As_long(__pyx_t_8); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_9 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_tx->__pyx_base.__pyx_vtab)->__pyx_base.c_get_genomic_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_tx), __pyx_t_4, 1); if (unlikely(__pyx_t_9 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_v_new_end = __pyx_t_9;

          /* "plastid/genomics/roitools.pyx":335
 *                     # of next exon. Instead, we should map to 1 + the genomic position
 *                     # of the end of the given exon.
 *                     for n,segment in enumerate(tx):             # <<<<<<<<<<<<<<
 *                         if new_end == segment.start:
 *                             new_end = tx[n-1].end
 */
          __pyx_t_10 = 0;
          if (likely(PyList_CheckExact(((PyObject *)__pyx_v_tx))) || PyTuple_CheckExact(((PyObject *)__pyx_v_tx))) {
            __pyx_t_8 = ((PyObject *)__pyx_v_tx); __Pyx_INCREF(__pyx_t_8); __pyx_t_11 = 0;
            __pyx_t_12 = NULL;
          } else {
            __pyx_t_11 = -1; __pyx_t_8 = PyObject_GetIter(((PyObject *)__pyx_v_tx)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __pyx_t_12 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          for (;;) {
            if (likely(!__pyx_t_12)) {
              if (likely(PyList_CheckExact(__pyx_t_8))) {
                if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_8)) break;
                #if CYTHON_COMPILING_IN_CPYTHON
                __pyx_t_7 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_7); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                #else
                __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_7);
                #endif
              } else {
                if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
                #if CYTHON_COMPILING_IN_CPYTHON
                __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_7); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                #else
                __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                __Pyx_GOTREF(__pyx_t_7);
                #endif
              }
            } else {
              __pyx_t_7 = __pyx_t_12(__pyx_t_8);
              if (unlikely(!__pyx_t_7)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_7);
            }
            __Pyx_XDECREF_SET(__pyx_v_segment, __pyx_t_7);
            __pyx_t_7 = 0;
            __pyx_v_n = __pyx_t_10;
            __pyx_t_10 = (__pyx_t_10 + 1);

            /* "plastid/genomics/roitools.pyx":336
 *                     # of the end of the given exon.
 *                     for n,segment in enumerate(tx):
 *                         if new_end == segment.start:             # <<<<<<<<<<<<<<
 *                             new_end = tx[n-1].end
 *         else:
 */
            __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_new_end); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_segment, __pyx_n_s_start); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_5 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (__pyx_t_1) {

              /* "plastid/genomics/roitools.pyx":337
 *                     for n,segment in enumerate(tx):
 *                         if new_end == segment.start:
 *                             new_end = tx[n-1].end             # <<<<<<<<<<<<<<
 *         else:
 *             # if cds starts at beginning of transcript, both need to grow by three
 */
              __pyx_t_9 = (__pyx_v_n - 1);
              __pyx_t_5 = __Pyx_GetItemInt(((PyObject *)__pyx_v_tx), __pyx_t_9, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_9 = __Pyx_PyInt_As_long(__pyx_t_6); if (unlikely((__pyx_t_9 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_v_new_end = __pyx_t_9;

              /* "plastid/genomics/roitools.pyx":336
 *                     # of the end of the given exon.
 *                     for n,segment in enumerate(tx):
 *                         if new_end == segment.start:             # <<<<<<<<<<<<<<
 *                             new_end = tx[n-1].end
 *         else:
 */
            }

            /* "plastid/genomics/roitools.pyx":335
 *                     # of next exon. Instead, we should map to 1 + the genomic position
 *                     # of the end of the given exon.
 *                     for n,segment in enumerate(tx):             # <<<<<<<<<<<<<<
 *                         if new_end == segment.start:
 *                             new_end = tx[n-1].end
 */
          }
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __pyx_L8:;
      }
      __pyx_L7:;

      /* "plastid/genomics/roitools.pyx":316
 *         span = tx.spanning_segment
 *         chrom = span.chrom
 *         if span.c_strand == forward_strand:             # <<<<<<<<<<<<<<
 *             # if cds at end of transcript, both need to grow by three
 *             if span.end == end:
 */
      goto __pyx_L6;
    }

    /* "plastid/genomics/roitools.pyx":340
 *         else:
 *             # if cds starts at beginning of transcript, both need to grow by three
 *             if span.start == start:             # <<<<<<<<<<<<<<
 *                 new_start = start - 3
 *                 old_seg = segments[0]
 */
    /*else*/ {
      __pyx_t_1 = ((__pyx_v_span->start == __pyx_v_start) != 0);
      if (__pyx_t_1) {

        /* "plastid/genomics/roitools.pyx":341
 *             # if cds starts at beginning of transcript, both need to grow by three
 *             if span.start == start:
 *                 new_start = start - 3             # <<<<<<<<<<<<<<
 *                 old_seg = segments[0]
 *                 new_seg = GenomicSegment(chrom,new_start,old_seg.end,span.strand)
 */
        __pyx_v_new_start = (__pyx_v_start - 3);

        /* "plastid/genomics/roitools.pyx":342
 *             if span.start == start:
 *                 new_start = start - 3
 *                 old_seg = segments[0]             # <<<<<<<<<<<<<<
 *                 new_seg = GenomicSegment(chrom,new_start,old_seg.end,span.strand)
 *                 segments[0] = new_seg
 */
        if (unlikely(__pyx_v_segments == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_segments, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_8);
        if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_old_seg = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_8);
        __pyx_t_8 = 0;

        /* "plastid/genomics/roitools.pyx":343
 *                 new_start = start - 3
 *                 old_seg = segments[0]
 *                 new_seg = GenomicSegment(chrom,new_start,old_seg.end,span.strand)             # <<<<<<<<<<<<<<
 *                 segments[0] = new_seg
 *             else:
 */
        __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_new_start); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_old_seg->end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_span), __pyx_n_s_strand); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_5);
        __pyx_t_8 = 0;
        __pyx_t_6 = 0;
        __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_v_new_seg = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_5);
        __pyx_t_5 = 0;

        /* "plastid/genomics/roitools.pyx":344
 *                 old_seg = segments[0]
 *                 new_seg = GenomicSegment(chrom,new_start,old_seg.end,span.strand)
 *                 segments[0] = new_seg             # <<<<<<<<<<<<<<
 *             else:
 *                 # otherwise, fetch
 */
        if (unlikely(__pyx_v_segments == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        if (unlikely(__Pyx_SetItemInt(__pyx_v_segments, 0, ((PyObject *)__pyx_v_new_seg), long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "plastid/genomics/roitools.pyx":340
 *         else:
 *             # if cds starts at beginning of transcript, both need to grow by three
 *             if span.start == start:             # <<<<<<<<<<<<<<
 *                 new_start = start - 3
 *                 old_seg = segments[0]
 */
        goto __pyx_L12;
      }

      /* "plastid/genomics/roitools.pyx":349
 *                 # minus one here might look funny, but is due to minus-strand
 *                 # feature-ness
 *                 new_start = tx.c_get_genomic_coordinate(tx.cds_end + 3 - 1,True)             # <<<<<<<<<<<<<<
 * 
 *         # since `segments` come from an existing transcript, we know they
 */
      /*else*/ {
        __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_v_tx->cds_end, __pyx_int_3, 3, 0); 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_7 = __Pyx_PyInt_SubtractObjC(__pyx_t_5, __pyx_int_1, 1, 0); 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_5); __pyx_t_5 = 0;
        __pyx_t_9 = __Pyx_PyInt_As_long(__pyx_t_7); if (unlikely((__pyx_t_9 == (long)-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_t_4 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_tx->__pyx_base.__pyx_vtab)->__pyx_base.c_get_genomic_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_tx), __pyx_t_9, 1); if (unlikely(__pyx_t_4 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_new_start = __pyx_t_4;
      }
      __pyx_L12:;
    }
    __pyx_L6:;

    /* "plastid/genomics/roitools.pyx":354
 *         # non-overlapping. So, we can bypass checks in __cinit__ and go through
 *         # faster set_segments()
 *         new_tx = Transcript()             # <<<<<<<<<<<<<<
 *         new_tx._set_segments(segments)
 *         new_tx.attr = attr
 */
    __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_v_new_tx = ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "plastid/genomics/roitools.pyx":355
 *         # faster set_segments()
 *         new_tx = Transcript()
 *         new_tx._set_segments(segments)             # <<<<<<<<<<<<<<
 *         new_tx.attr = attr
 *         new_tx.cds_genome_start = new_start
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_new_tx->__pyx_base.__pyx_vtab)->__pyx_base._set_segments(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_new_tx), __pyx_v_segments); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":356
 *         new_tx = Transcript()
 *         new_tx._set_segments(segments)
 *         new_tx.attr = attr             # <<<<<<<<<<<<<<
 *         new_tx.cds_genome_start = new_start
 *         new_tx.cds_genome_end = new_end
 */
    __Pyx_INCREF(__pyx_v_attr);
    __Pyx_GIVEREF(__pyx_v_attr);
    __Pyx_GOTREF(__pyx_v_new_tx->__pyx_base.attr);
    __Pyx_DECREF(__pyx_v_new_tx->__pyx_base.attr);
    __pyx_v_new_tx->__pyx_base.attr = __pyx_v_attr;

    /* "plastid/genomics/roitools.pyx":357
 *         new_tx._set_segments(segments)
 *         new_tx.attr = attr
 *         new_tx.cds_genome_start = new_start             # <<<<<<<<<<<<<<
 *         new_tx.cds_genome_end = new_end
 *         new_tx._update_cds()
 */
    __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_new_start); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __Pyx_GOTREF(__pyx_v_new_tx->cds_genome_start);
    __Pyx_DECREF(__pyx_v_new_tx->cds_genome_start);
    __pyx_v_new_tx->cds_genome_start = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "plastid/genomics/roitools.pyx":358
 *         new_tx.attr = attr
 *         new_tx.cds_genome_start = new_start
 *         new_tx.cds_genome_end = new_end             # <<<<<<<<<<<<<<
 *         new_tx._update_cds()
 *         return new_tx
 */
    __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_new_end); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __Pyx_GOTREF(__pyx_v_new_tx->cds_genome_end);
    __Pyx_DECREF(__pyx_v_new_tx->cds_genome_end);
    __pyx_v_new_tx->cds_genome_end = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "plastid/genomics/roitools.pyx":359
 *         new_tx.cds_genome_start = new_start
 *         new_tx.cds_genome_end = new_end
 *         new_tx._update_cds()             # <<<<<<<<<<<<<<
 *         return new_tx
 *     else:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_new_tx->__pyx_base.__pyx_vtab)->_update_cds(__pyx_v_new_tx); if (unlikely(__pyx_t_1 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":360
 *         new_tx.cds_genome_end = new_end
 *         new_tx._update_cds()
 *         return new_tx             # <<<<<<<<<<<<<<
 *     else:
 *         return tx
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_new_tx));
    __pyx_r = __pyx_v_new_tx;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":309
 *         Transcript new_tx
 * 
 *     if tx.cds_genome_end is not None and tx.cds_genome_start is not None:             # <<<<<<<<<<<<<<
 *         new_start = start = <long>tx.cds_genome_start
 *         new_end = end = <long>tx.cds_genome_end
 */
  }

  /* "plastid/genomics/roitools.pyx":362
 *         return new_tx
 *     else:
 *         return tx             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_tx));
    __pyx_r = __pyx_v_tx;
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":281
 * 
 * 
 * cpdef Transcript add_three_for_stop_codon(Transcript tx):             # <<<<<<<<<<<<<<
 *     """Extend an annotated CDS region, if present, by three nucleotides
 *     at the threeprime end. Use in cases when annotation files exclude the stop
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("plastid.genomics.roitools.add_three_for_stop_codon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_span);
  __Pyx_XDECREF((PyObject *)__pyx_v_new_seg);
  __Pyx_XDECREF((PyObject *)__pyx_v_old_seg);
  __Pyx_XDECREF(__pyx_v_segments);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF((PyObject *)__pyx_v_new_tx);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_segment);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_11add_three_for_stop_codon(PyObject *__pyx_self, PyObject *__pyx_v_tx); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10add_three_for_stop_codon[] = "add_three_for_stop_codon(Transcript tx) -> Transcript\nExtend an annotated CDS region, if present, by three nucleotides\n    at the threeprime end. Use in cases when annotation files exclude the stop\n    codon from the annotated CDS.\n    \n    Parameters\n    ----------\n    tx : |Transcript|\n        query transcript\n        \n    Returns\n    -------\n    |Transcript|\n        |Transcript| with same attributes as `tx`, but with CDS extended by one codon\n    \n    Raises\n    ------\n    IndexError\n        if a three prime UTR is defined that terminates before the complete stop codon\n    ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_11add_three_for_stop_codon(PyObject *__pyx_self, PyObject *__pyx_v_tx) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_three_for_stop_codon (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tx), __pyx_ptype_7plastid_8genomics_8roitools_Transcript, 1, "tx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10add_three_for_stop_codon(__pyx_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_tx));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10add_three_for_stop_codon(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_tx) {
  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_three_for_stop_codon", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_7plastid_8genomics_8roitools_add_three_for_stop_codon(__pyx_v_tx, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.add_three_for_stop_codon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":369
 * #==============================================================================
 * 
 * cdef void nonecheck(object obj,str place, str valname):             # <<<<<<<<<<<<<<
 *     """Propagate errors if incoming objects are None"""
 *     if obj is None:
 */

static void __pyx_f_7plastid_8genomics_8roitools_nonecheck(PyObject *__pyx_v_obj, PyObject *__pyx_v_place, PyObject *__pyx_v_valname) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  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("nonecheck", 0);

  /* "plastid/genomics/roitools.pyx":371
 * cdef void nonecheck(object obj,str place, str valname):
 *     """Propagate errors if incoming objects are None"""
 *     if obj is None:             # <<<<<<<<<<<<<<
 *         raise ValueError("%s: value of %s cannot be None" % (place,valname))
 * 
 */
  __pyx_t_1 = (__pyx_v_obj == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":372
 *     """Propagate errors if incoming objects are None"""
 *     if obj is None:
 *         raise ValueError("%s: value of %s cannot be None" % (place,valname))             # <<<<<<<<<<<<<<
 * 
 * cdef str strand_to_str(Strand strand):
 */
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_place);
    __Pyx_GIVEREF(__pyx_v_place);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_place);
    __Pyx_INCREF(__pyx_v_valname);
    __Pyx_GIVEREF(__pyx_v_valname);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_valname);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_value_of_s_cannot_be_None, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__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 = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__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 = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":371
 * cdef void nonecheck(object obj,str place, str valname):
 *     """Propagate errors if incoming objects are None"""
 *     if obj is None:             # <<<<<<<<<<<<<<
 *         raise ValueError("%s: value of %s cannot be None" % (place,valname))
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":369
 * #==============================================================================
 * 
 * cdef void nonecheck(object obj,str place, str valname):             # <<<<<<<<<<<<<<
 *     """Propagate errors if incoming objects are None"""
 *     if obj is None:
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("plastid.genomics.roitools.nonecheck", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "plastid/genomics/roitools.pyx":374
 *         raise ValueError("%s: value of %s cannot be None" % (place,valname))
 * 
 * cdef str strand_to_str(Strand strand):             # <<<<<<<<<<<<<<
 *     """Convert enum Strand to str representation"""
 *     if strand == forward_strand:
 */

static PyObject *__pyx_f_7plastid_8genomics_8roitools_strand_to_str(enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_strand) {
  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("strand_to_str", 0);

  /* "plastid/genomics/roitools.pyx":376
 * cdef str strand_to_str(Strand strand):
 *     """Convert enum Strand to str representation"""
 *     if strand == forward_strand:             # <<<<<<<<<<<<<<
 *         return "+"
 *     elif strand == reverse_strand:
 */
  switch (__pyx_v_strand) {
    case __pyx_e_7plastid_8genomics_8c_common_forward_strand:

    /* "plastid/genomics/roitools.pyx":377
 *     """Convert enum Strand to str representation"""
 *     if strand == forward_strand:
 *         return "+"             # <<<<<<<<<<<<<<
 *     elif strand == reverse_strand:
 *         return "-"
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__2);
    __pyx_r = __pyx_kp_s__2;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":376
 * cdef str strand_to_str(Strand strand):
 *     """Convert enum Strand to str representation"""
 *     if strand == forward_strand:             # <<<<<<<<<<<<<<
 *         return "+"
 *     elif strand == reverse_strand:
 */
    break;

    /* "plastid/genomics/roitools.pyx":378
 *     if strand == forward_strand:
 *         return "+"
 *     elif strand == reverse_strand:             # <<<<<<<<<<<<<<
 *         return "-"
 *     elif strand == unstranded:
 */
    case __pyx_e_7plastid_8genomics_8c_common_reverse_strand:

    /* "plastid/genomics/roitools.pyx":379
 *         return "+"
 *     elif strand == reverse_strand:
 *         return "-"             # <<<<<<<<<<<<<<
 *     elif strand == unstranded:
 *         return "."
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__3);
    __pyx_r = __pyx_kp_s__3;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":378
 *     if strand == forward_strand:
 *         return "+"
 *     elif strand == reverse_strand:             # <<<<<<<<<<<<<<
 *         return "-"
 *     elif strand == unstranded:
 */
    break;

    /* "plastid/genomics/roitools.pyx":380
 *     elif strand == reverse_strand:
 *         return "-"
 *     elif strand == unstranded:             # <<<<<<<<<<<<<<
 *         return "."
 *     elif strand == undef_strand:
 */
    case __pyx_e_7plastid_8genomics_8c_common_unstranded:

    /* "plastid/genomics/roitools.pyx":381
 *         return "-"
 *     elif strand == unstranded:
 *         return "."             # <<<<<<<<<<<<<<
 *     elif strand == undef_strand:
 *         return "strand undefined"
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__4);
    __pyx_r = __pyx_kp_s__4;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":380
 *     elif strand == reverse_strand:
 *         return "-"
 *     elif strand == unstranded:             # <<<<<<<<<<<<<<
 *         return "."
 *     elif strand == undef_strand:
 */
    break;

    /* "plastid/genomics/roitools.pyx":382
 *     elif strand == unstranded:
 *         return "."
 *     elif strand == undef_strand:             # <<<<<<<<<<<<<<
 *         return "strand undefined"
 *     else:
 */
    case __pyx_e_7plastid_8genomics_8c_common_undef_strand:

    /* "plastid/genomics/roitools.pyx":383
 *         return "."
 *     elif strand == undef_strand:
 *         return "strand undefined"             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError("strand_to_str: Strand must be forward (%s), reverse (%s), or unstranded(%s). Got '%s'" % (forward_strand,
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s_strand_undefined);
    __pyx_r = __pyx_kp_s_strand_undefined;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":382
 *     elif strand == unstranded:
 *         return "."
 *     elif strand == undef_strand:             # <<<<<<<<<<<<<<
 *         return "strand undefined"
 *     else:
 */
    break;
    default:

    /* "plastid/genomics/roitools.pyx":385
 *         return "strand undefined"
 *     else:
 *         raise ValueError("strand_to_str: Strand must be forward (%s), reverse (%s), or unstranded(%s). Got '%s'" % (forward_strand,             # <<<<<<<<<<<<<<
 *             reverse_strand, unstranded, strand))
 * 
 */
    __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_e_7plastid_8genomics_8c_common_forward_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);

    /* "plastid/genomics/roitools.pyx":386
 *     else:
 *         raise ValueError("strand_to_str: Strand must be forward (%s), reverse (%s), or unstranded(%s). Got '%s'" % (forward_strand,
 *             reverse_strand, unstranded, strand))             # <<<<<<<<<<<<<<
 * 
 * cdef Strand str_to_strand(str val):
 */
    __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_e_7plastid_8genomics_8c_common_reverse_strand); 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_3 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_e_7plastid_8genomics_8c_common_unstranded); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_v_strand); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);

    /* "plastid/genomics/roitools.pyx":385
 *         return "strand undefined"
 *     else:
 *         raise ValueError("strand_to_str: Strand must be forward (%s), reverse (%s), or unstranded(%s). Got '%s'" % (forward_strand,             # <<<<<<<<<<<<<<
 *             reverse_strand, unstranded, strand))
 * 
 */
    __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_strand_to_str_Strand_must_be_for, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__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 = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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 = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  /* "plastid/genomics/roitools.pyx":374
 *         raise ValueError("%s: value of %s cannot be None" % (place,valname))
 * 
 * cdef str strand_to_str(Strand strand):             # <<<<<<<<<<<<<<
 *     """Convert enum Strand to str representation"""
 *     if strand == forward_strand:
 */

  /* function exit code */
  __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("plastid.genomics.roitools.strand_to_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":388
 *             reverse_strand, unstranded, strand))
 * 
 * cdef Strand str_to_strand(str val):             # <<<<<<<<<<<<<<
 *     """Convert str representation of strand to enum"""
 *     if val == "+":
 */

static enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_f_7plastid_8genomics_8roitools_str_to_strand(PyObject *__pyx_v_val) {
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_r;
  __Pyx_RefNannyDeclarations
  int __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("str_to_strand", 0);

  /* "plastid/genomics/roitools.pyx":390
 * cdef Strand str_to_strand(str val):
 *     """Convert str representation of strand to enum"""
 *     if val == "+":             # <<<<<<<<<<<<<<
 *         return forward_strand
 *     elif val == "-":
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_val, __pyx_kp_s__2, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":391
 *     """Convert str representation of strand to enum"""
 *     if val == "+":
 *         return forward_strand             # <<<<<<<<<<<<<<
 *     elif val == "-":
 *         return reverse_strand
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_forward_strand;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":390
 * cdef Strand str_to_strand(str val):
 *     """Convert str representation of strand to enum"""
 *     if val == "+":             # <<<<<<<<<<<<<<
 *         return forward_strand
 *     elif val == "-":
 */
  }

  /* "plastid/genomics/roitools.pyx":392
 *     if val == "+":
 *         return forward_strand
 *     elif val == "-":             # <<<<<<<<<<<<<<
 *         return reverse_strand
 *     elif val == ".":
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_val, __pyx_kp_s__3, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":393
 *         return forward_strand
 *     elif val == "-":
 *         return reverse_strand             # <<<<<<<<<<<<<<
 *     elif val == ".":
 *         return unstranded
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_reverse_strand;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":392
 *     if val == "+":
 *         return forward_strand
 *     elif val == "-":             # <<<<<<<<<<<<<<
 *         return reverse_strand
 *     elif val == ".":
 */
  }

  /* "plastid/genomics/roitools.pyx":394
 *     elif val == "-":
 *         return reverse_strand
 *     elif val == ".":             # <<<<<<<<<<<<<<
 *         return unstranded
 *     elif val == "\x00":
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_val, __pyx_kp_s__4, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":395
 *         return reverse_strand
 *     elif val == ".":
 *         return unstranded             # <<<<<<<<<<<<<<
 *     elif val == "\x00":
 *         return undef_strand
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_unstranded;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":394
 *     elif val == "-":
 *         return reverse_strand
 *     elif val == ".":             # <<<<<<<<<<<<<<
 *         return unstranded
 *     elif val == "\x00":
 */
  }

  /* "plastid/genomics/roitools.pyx":396
 *     elif val == ".":
 *         return unstranded
 *     elif val == "\x00":             # <<<<<<<<<<<<<<
 *         return undef_strand
 *     else:
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_val, __pyx_kp_s__5, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":397
 *         return unstranded
 *     elif val == "\x00":
 *         return undef_strand             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError("Strand must be '+', '-', '.', or '\\x00' (undefined)")
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_undef_strand;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":396
 *     elif val == ".":
 *         return unstranded
 *     elif val == "\x00":             # <<<<<<<<<<<<<<
 *         return undef_strand
 *     else:
 */
  }

  /* "plastid/genomics/roitools.pyx":399
 *         return undef_strand
 *     else:
 *         raise ValueError("Strand must be '+', '-', '.', or '\\x00' (undefined)")             # <<<<<<<<<<<<<<
 * 
 * cdef bint check_segments(SegmentChain chain, tuple segments) except False:
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __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 = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":388
 *             reverse_strand, unstranded, strand))
 * 
 * cdef Strand str_to_strand(str val):             # <<<<<<<<<<<<<<
 *     """Convert str representation of strand to enum"""
 *     if val == "+":
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("plastid.genomics.roitools.str_to_strand", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = (enum __pyx_t_7plastid_8genomics_8c_common_Strand) 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":401
 *         raise ValueError("Strand must be '+', '-', '.', or '\\x00' (undefined)")
 * 
 * cdef bint check_segments(SegmentChain chain, tuple segments) except False:             # <<<<<<<<<<<<<<
 *     cdef:
 *         GenomicSegment seg, seg0
 */

static int __pyx_f_7plastid_8genomics_8roitools_check_segments(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_chain, PyObject *__pyx_v_segments) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg0 = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_span = 0;
  PyObject *__pyx_v_my_chrom = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_my_strand;
  int __pyx_v_i;
  int __pyx_v_length;
  int __pyx_v_prob;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_v_X = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  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("check_segments", 0);

  /* "plastid/genomics/roitools.pyx":404
 *     cdef:
 *         GenomicSegment seg, seg0
 *         GenomicSegment span = chain.spanning_segment             # <<<<<<<<<<<<<<
 *         str my_chrom  = span.chrom
 *         Strand my_strand = span.c_strand
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_chain->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_span = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":405
 *         GenomicSegment seg, seg0
 *         GenomicSegment span = chain.spanning_segment
 *         str my_chrom  = span.chrom             # <<<<<<<<<<<<<<
 *         Strand my_strand = span.c_strand
 *         int i = 0
 */
  __pyx_t_1 = __pyx_v_span->chrom;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_my_chrom = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":406
 *         GenomicSegment span = chain.spanning_segment
 *         str my_chrom  = span.chrom
 *         Strand my_strand = span.c_strand             # <<<<<<<<<<<<<<
 *         int i = 0
 *         int length = len(segments)
 */
  __pyx_t_2 = __pyx_v_span->c_strand;
  __pyx_v_my_strand = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":407
 *         str my_chrom  = span.chrom
 *         Strand my_strand = span.c_strand
 *         int i = 0             # <<<<<<<<<<<<<<
 *         int length = len(segments)
 *         bint prob = False
 */
  __pyx_v_i = 0;

  /* "plastid/genomics/roitools.pyx":408
 *         Strand my_strand = span.c_strand
 *         int i = 0
 *         int length = len(segments)             # <<<<<<<<<<<<<<
 *         bint prob = False
 * 
 */
  if (unlikely(__pyx_v_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v_segments); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_length = __pyx_t_3;

  /* "plastid/genomics/roitools.pyx":409
 *         int i = 0
 *         int length = len(segments)
 *         bint prob = False             # <<<<<<<<<<<<<<
 * 
 *     if length > 0:
 */
  __pyx_v_prob = 0;

  /* "plastid/genomics/roitools.pyx":411
 *         bint prob = False
 * 
 *     if length > 0:             # <<<<<<<<<<<<<<
 *         msg = "SegmentChain.add_segments: incoming segments (%s) mismatch chain '%s'"
 *         seg0 = segments[0]
 */
  __pyx_t_4 = ((__pyx_v_length > 0) != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":412
 * 
 *     if length > 0:
 *         msg = "SegmentChain.add_segments: incoming segments (%s) mismatch chain '%s'"             # <<<<<<<<<<<<<<
 *         seg0 = segments[0]
 *         if len(chain._segments) == 0:
 */
    __Pyx_INCREF(__pyx_kp_s_SegmentChain_add_segments_incomi);
    __pyx_v_msg = __pyx_kp_s_SegmentChain_add_segments_incomi;

    /* "plastid/genomics/roitools.pyx":413
 *     if length > 0:
 *         msg = "SegmentChain.add_segments: incoming segments (%s) mismatch chain '%s'"
 *         seg0 = segments[0]             # <<<<<<<<<<<<<<
 *         if len(chain._segments) == 0:
 *             my_chrom  = seg0.chrom
 */
    if (unlikely(__pyx_v_segments == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_segments, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_seg0 = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":414
 *         msg = "SegmentChain.add_segments: incoming segments (%s) mismatch chain '%s'"
 *         seg0 = segments[0]
 *         if len(chain._segments) == 0:             # <<<<<<<<<<<<<<
 *             my_chrom  = seg0.chrom
 *             my_strand = seg0.c_strand
 */
    __pyx_t_1 = __pyx_v_chain->_segments;
    __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 = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
    if (__pyx_t_4) {

      /* "plastid/genomics/roitools.pyx":415
 *         seg0 = segments[0]
 *         if len(chain._segments) == 0:
 *             my_chrom  = seg0.chrom             # <<<<<<<<<<<<<<
 *             my_strand = seg0.c_strand
 * 
 */
      __pyx_t_1 = __pyx_v_seg0->chrom;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_my_chrom, ((PyObject*)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "plastid/genomics/roitools.pyx":416
 *         if len(chain._segments) == 0:
 *             my_chrom  = seg0.chrom
 *             my_strand = seg0.c_strand             # <<<<<<<<<<<<<<
 * 
 *         while i < length:
 */
      __pyx_t_2 = __pyx_v_seg0->c_strand;
      __pyx_v_my_strand = __pyx_t_2;

      /* "plastid/genomics/roitools.pyx":414
 *         msg = "SegmentChain.add_segments: incoming segments (%s) mismatch chain '%s'"
 *         seg0 = segments[0]
 *         if len(chain._segments) == 0:             # <<<<<<<<<<<<<<
 *             my_chrom  = seg0.chrom
 *             my_strand = seg0.c_strand
 */
    }

    /* "plastid/genomics/roitools.pyx":418
 *             my_strand = seg0.c_strand
 * 
 *         while i < length:             # <<<<<<<<<<<<<<
 *             seg = segments[i]
 *             if seg.chrom != my_chrom:
 */
    while (1) {
      __pyx_t_4 = ((__pyx_v_i < __pyx_v_length) != 0);
      if (!__pyx_t_4) break;

      /* "plastid/genomics/roitools.pyx":419
 * 
 *         while i < length:
 *             seg = segments[i]             # <<<<<<<<<<<<<<
 *             if seg.chrom != my_chrom:
 *                 msg += "; wrong and/or multiple chromosomes"
 */
      if (unlikely(__pyx_v_segments == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_segments, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF_SET(__pyx_v_seg, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "plastid/genomics/roitools.pyx":420
 *         while i < length:
 *             seg = segments[i]
 *             if seg.chrom != my_chrom:             # <<<<<<<<<<<<<<
 *                 msg += "; wrong and/or multiple chromosomes"
 *                 prob = True
 */
      __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_seg->chrom, __pyx_v_my_chrom, Py_NE)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = (__pyx_t_4 != 0);
      if (__pyx_t_5) {

        /* "plastid/genomics/roitools.pyx":421
 *             seg = segments[i]
 *             if seg.chrom != my_chrom:
 *                 msg += "; wrong and/or multiple chromosomes"             # <<<<<<<<<<<<<<
 *                 prob = True
 *                 break
 */
        __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_kp_s_wrong_and_or_multiple_chromosom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "plastid/genomics/roitools.pyx":422
 *             if seg.chrom != my_chrom:
 *                 msg += "; wrong and/or multiple chromosomes"
 *                 prob = True             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
        __pyx_v_prob = 1;

        /* "plastid/genomics/roitools.pyx":423
 *                 msg += "; wrong and/or multiple chromosomes"
 *                 prob = True
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             if seg.c_strand != my_strand:
 */
        goto __pyx_L6_break;

        /* "plastid/genomics/roitools.pyx":420
 *         while i < length:
 *             seg = segments[i]
 *             if seg.chrom != my_chrom:             # <<<<<<<<<<<<<<
 *                 msg += "; wrong and/or multiple chromosomes"
 *                 prob = True
 */
      }

      /* "plastid/genomics/roitools.pyx":425
 *                 break
 * 
 *             if seg.c_strand != my_strand:             # <<<<<<<<<<<<<<
 *                 msg += "; wrong and/or multiple strands"
 *                 prob = True
 */
      __pyx_t_5 = ((__pyx_v_seg->c_strand != __pyx_v_my_strand) != 0);
      if (__pyx_t_5) {

        /* "plastid/genomics/roitools.pyx":426
 * 
 *             if seg.c_strand != my_strand:
 *                 msg += "; wrong and/or multiple strands"             # <<<<<<<<<<<<<<
 *                 prob = True
 *                 break
 */
        __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_msg, __pyx_kp_s_wrong_and_or_multiple_strands); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "plastid/genomics/roitools.pyx":427
 *             if seg.c_strand != my_strand:
 *                 msg += "; wrong and/or multiple strands"
 *                 prob = True             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
        __pyx_v_prob = 1;

        /* "plastid/genomics/roitools.pyx":428
 *                 msg += "; wrong and/or multiple strands"
 *                 prob = True
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             i += 1
 */
        goto __pyx_L6_break;

        /* "plastid/genomics/roitools.pyx":425
 *                 break
 * 
 *             if seg.c_strand != my_strand:             # <<<<<<<<<<<<<<
 *                 msg += "; wrong and/or multiple strands"
 *                 prob = True
 */
      }

      /* "plastid/genomics/roitools.pyx":430
 *                 break
 * 
 *             i += 1             # <<<<<<<<<<<<<<
 * 
 *         if prob == True:
 */
      __pyx_v_i = (__pyx_v_i + 1);
    }
    __pyx_L6_break:;

    /* "plastid/genomics/roitools.pyx":432
 *             i += 1
 * 
 *         if prob == True:             # <<<<<<<<<<<<<<
 *             msg = msg % (", ".join([str(X) for X in segments]),chain)
 *             raise ValueError(msg)
 */
    __pyx_t_5 = ((__pyx_v_prob == 1) != 0);
    if (__pyx_t_5) {

      /* "plastid/genomics/roitools.pyx":433
 * 
 *         if prob == True:
 *             msg = msg % (", ".join([str(X) for X in segments]),chain)             # <<<<<<<<<<<<<<
 *             raise ValueError(msg)
 * 
 */
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(__pyx_v_segments == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = __pyx_v_segments; __Pyx_INCREF(__pyx_t_6); __pyx_t_3 = 0;
      for (;;) {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_t_7); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_XDECREF_SET(__pyx_v_X, __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 = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_v_X);
        __Pyx_GIVEREF(__pyx_v_X);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_X);
        __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __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 = __Pyx_PyString_Join(__pyx_kp_s__7, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __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 = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
      __Pyx_INCREF(((PyObject *)__pyx_v_chain));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_chain));
      PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_chain));
      __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Remainder(__pyx_v_msg, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_msg, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "plastid/genomics/roitools.pyx":434
 *         if prob == True:
 *             msg = msg % (", ".join([str(X) for X in segments]),chain)
 *             raise ValueError(msg)             # <<<<<<<<<<<<<<
 * 
 *     return True
 */
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_msg);
      __Pyx_GIVEREF(__pyx_v_msg);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_msg);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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 = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":432
 *             i += 1
 * 
 *         if prob == True:             # <<<<<<<<<<<<<<
 *             msg = msg % (", ".join([str(X) for X in segments]),chain)
 *             raise ValueError(msg)
 */
    }

    /* "plastid/genomics/roitools.pyx":411
 *         bint prob = False
 * 
 *     if length > 0:             # <<<<<<<<<<<<<<
 *         msg = "SegmentChain.add_segments: incoming segments (%s) mismatch chain '%s'"
 *         seg0 = segments[0]
 */
  }

  /* "plastid/genomics/roitools.pyx":436
 *             raise ValueError(msg)
 * 
 *     return True             # <<<<<<<<<<<<<<
 * 
 * cdef ExBool chain_richcmp(SegmentChain chain1, SegmentChain chain2, int cmpval) except bool_exception:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":401
 *         raise ValueError("Strand must be '+', '-', '.', or '\\x00' (undefined)")
 * 
 * cdef bint check_segments(SegmentChain chain, tuple segments) except False:             # <<<<<<<<<<<<<<
 *     cdef:
 *         GenomicSegment seg, seg0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("plastid.genomics.roitools.check_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_seg);
  __Pyx_XDECREF((PyObject *)__pyx_v_seg0);
  __Pyx_XDECREF((PyObject *)__pyx_v_span);
  __Pyx_XDECREF(__pyx_v_my_chrom);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":438
 *     return True
 * 
 * cdef ExBool chain_richcmp(SegmentChain chain1, SegmentChain chain2, int cmpval) except bool_exception:             # <<<<<<<<<<<<<<
 *     """Helper method for rich comparisons (==, !=, <, >, <=, >=) of |SegmentChains|
 * 
 */

static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_chain1, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_chain2, int __pyx_v_cmpval) {
  PyObject *__pyx_v_sspan = 0;
  PyObject *__pyx_v_ospan = 0;
  PyObject *__pyx_v_sname = 0;
  PyObject *__pyx_v_oname = 0;
  long __pyx_v_slen;
  long __pyx_v_olen;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_7;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_8;
  long __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("chain_richcmp", 0);

  /* "plastid/genomics/roitools.pyx":470
 *     """
 *     cdef:
 *         sspan = chain1.spanning_segment             # <<<<<<<<<<<<<<
 *         ospan = chain2.spanning_segment
 *         str sname, oname
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_chain1->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_sspan = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":471
 *     cdef:
 *         sspan = chain1.spanning_segment
 *         ospan = chain2.spanning_segment             # <<<<<<<<<<<<<<
 *         str sname, oname
 *         long slen, olen
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_chain2->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ospan = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":475
 *         long slen, olen
 * 
 *     if cmpval == EQ:             # <<<<<<<<<<<<<<
 *         if len(chain1) == 0 or len(chain2) == 0:
 *             return false
 */
  switch (__pyx_v_cmpval) {
    case 2:

    /* "plastid/genomics/roitools.pyx":476
 * 
 *     if cmpval == EQ:
 *         if len(chain1) == 0 or len(chain2) == 0:             # <<<<<<<<<<<<<<
 *             return false
 *         else:
 */
    __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_chain1)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_chain2)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L4_bool_binop_done:;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":477
 *     if cmpval == EQ:
 *         if len(chain1) == 0 or len(chain2) == 0:
 *             return false             # <<<<<<<<<<<<<<
 *         else:
 *             if sspan.chrom == ospan.chrom and\
 */
      __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":476
 * 
 *     if cmpval == EQ:
 *         if len(chain1) == 0 or len(chain2) == 0:             # <<<<<<<<<<<<<<
 *             return false
 *         else:
 */
    }

    /* "plastid/genomics/roitools.pyx":479
 *             return false
 *         else:
 *             if sspan.chrom == ospan.chrom and\             # <<<<<<<<<<<<<<
 *                sspan.c_strand == ospan.c_strand and\
 *                chain1.c_get_position_list() == chain2.c_get_position_list():
 */
    /*else*/ {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sspan, __pyx_n_s_chrom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_ospan, __pyx_n_s_chrom); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_4) {
      } else {
        __pyx_t_2 = __pyx_t_4;
        goto __pyx_L7_bool_binop_done;
      }

      /* "plastid/genomics/roitools.pyx":480
 *         else:
 *             if sspan.chrom == ospan.chrom and\
 *                sspan.c_strand == ospan.c_strand and\             # <<<<<<<<<<<<<<
 *                chain1.c_get_position_list() == chain2.c_get_position_list():
 *                    return true
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_sspan, __pyx_n_s_c_strand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_ospan, __pyx_n_s_c_strand); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_4) {
      } else {
        __pyx_t_2 = __pyx_t_4;
        goto __pyx_L7_bool_binop_done;
      }

      /* "plastid/genomics/roitools.pyx":481
 *             if sspan.chrom == ospan.chrom and\
 *                sspan.c_strand == ospan.c_strand and\
 *                chain1.c_get_position_list() == chain2.c_get_position_list():             # <<<<<<<<<<<<<<
 *                    return true
 *             return false
 */
      __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain1->__pyx_vtab)->c_get_position_list(__pyx_v_chain1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2->__pyx_vtab)->c_get_position_list(__pyx_v_chain2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_2 = __pyx_t_4;
      __pyx_L7_bool_binop_done:;

      /* "plastid/genomics/roitools.pyx":479
 *             return false
 *         else:
 *             if sspan.chrom == ospan.chrom and\             # <<<<<<<<<<<<<<
 *                sspan.c_strand == ospan.c_strand and\
 *                chain1.c_get_position_list() == chain2.c_get_position_list():
 */
      if (__pyx_t_2) {

        /* "plastid/genomics/roitools.pyx":482
 *                sspan.c_strand == ospan.c_strand and\
 *                chain1.c_get_position_list() == chain2.c_get_position_list():
 *                    return true             # <<<<<<<<<<<<<<
 *             return false
 *     elif cmpval == NEQ:
 */
        __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
        goto __pyx_L0;

        /* "plastid/genomics/roitools.pyx":479
 *             return false
 *         else:
 *             if sspan.chrom == ospan.chrom and\             # <<<<<<<<<<<<<<
 *                sspan.c_strand == ospan.c_strand and\
 *                chain1.c_get_position_list() == chain2.c_get_position_list():
 */
      }

      /* "plastid/genomics/roitools.pyx":483
 *                chain1.c_get_position_list() == chain2.c_get_position_list():
 *                    return true
 *             return false             # <<<<<<<<<<<<<<
 *     elif cmpval == NEQ:
 *         return true if chain_richcmp(chain1,chain2,EQ) == false else true
 */
      __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
      goto __pyx_L0;
    }

    /* "plastid/genomics/roitools.pyx":475
 *         long slen, olen
 * 
 *     if cmpval == EQ:             # <<<<<<<<<<<<<<
 *         if len(chain1) == 0 or len(chain2) == 0:
 *             return false
 */
    break;

    /* "plastid/genomics/roitools.pyx":484
 *                    return true
 *             return false
 *     elif cmpval == NEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:
 */
    case 3:

    /* "plastid/genomics/roitools.pyx":485
 *             return false
 *     elif cmpval == NEQ:
 *         return true if chain_richcmp(chain1,chain2,EQ) == false else true             # <<<<<<<<<<<<<<
 *     elif cmpval == LT:
 *         if sspan < ospan:
 */
    __pyx_t_8 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(__pyx_v_chain1, __pyx_v_chain2, 2); if (unlikely(__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (((__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_false) != 0)) {
      __pyx_t_7 = __pyx_e_7plastid_8genomics_8c_common_true;
    } else {
      __pyx_t_7 = __pyx_e_7plastid_8genomics_8c_common_true;
    }
    __pyx_r = __pyx_t_7;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":484
 *                    return true
 *             return false
 *     elif cmpval == NEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:
 */
    break;

    /* "plastid/genomics/roitools.pyx":486
 *     elif cmpval == NEQ:
 *         return true if chain_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:             # <<<<<<<<<<<<<<
 *         if sspan < ospan:
 *             return true
 */
    case 0:

    /* "plastid/genomics/roitools.pyx":487
 *         return true if chain_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:
 *         if sspan < ospan:             # <<<<<<<<<<<<<<
 *             return true
 *         elif sspan > ospan:
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_sspan, __pyx_v_ospan, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":488
 *     elif cmpval == LT:
 *         if sspan < ospan:
 *             return true             # <<<<<<<<<<<<<<
 *         elif sspan > ospan:
 *             return false
 */
      __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":487
 *         return true if chain_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:
 *         if sspan < ospan:             # <<<<<<<<<<<<<<
 *             return true
 *         elif sspan > ospan:
 */
    }

    /* "plastid/genomics/roitools.pyx":489
 *         if sspan < ospan:
 *             return true
 *         elif sspan > ospan:             # <<<<<<<<<<<<<<
 *             return false
 *         else:
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_sspan, __pyx_v_ospan, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":490
 *             return true
 *         elif sspan > ospan:
 *             return false             # <<<<<<<<<<<<<<
 *         else:
 *             slen = chain1.length
 */
      __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":489
 *         if sspan < ospan:
 *             return true
 *         elif sspan > ospan:             # <<<<<<<<<<<<<<
 *             return false
 *         else:
 */
    }

    /* "plastid/genomics/roitools.pyx":492
 *             return false
 *         else:
 *             slen = chain1.length             # <<<<<<<<<<<<<<
 *             olen = chain2.length
 *             if slen < olen:
 */
    /*else*/ {
      __pyx_t_9 = __pyx_v_chain1->length;
      __pyx_v_slen = __pyx_t_9;

      /* "plastid/genomics/roitools.pyx":493
 *         else:
 *             slen = chain1.length
 *             olen = chain2.length             # <<<<<<<<<<<<<<
 *             if slen < olen:
 *                 return true
 */
      __pyx_t_9 = __pyx_v_chain2->length;
      __pyx_v_olen = __pyx_t_9;

      /* "plastid/genomics/roitools.pyx":494
 *             slen = chain1.length
 *             olen = chain2.length
 *             if slen < olen:             # <<<<<<<<<<<<<<
 *                 return true
 *             elif slen > olen:
 */
      __pyx_t_2 = ((__pyx_v_slen < __pyx_v_olen) != 0);
      if (__pyx_t_2) {

        /* "plastid/genomics/roitools.pyx":495
 *             olen = chain2.length
 *             if slen < olen:
 *                 return true             # <<<<<<<<<<<<<<
 *             elif slen > olen:
 *                 return false
 */
        __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
        goto __pyx_L0;

        /* "plastid/genomics/roitools.pyx":494
 *             slen = chain1.length
 *             olen = chain2.length
 *             if slen < olen:             # <<<<<<<<<<<<<<
 *                 return true
 *             elif slen > olen:
 */
      }

      /* "plastid/genomics/roitools.pyx":496
 *             if slen < olen:
 *                 return true
 *             elif slen > olen:             # <<<<<<<<<<<<<<
 *                 return false
 *             else:
 */
      __pyx_t_2 = ((__pyx_v_slen > __pyx_v_olen) != 0);
      if (__pyx_t_2) {

        /* "plastid/genomics/roitools.pyx":497
 *                 return true
 *             elif slen > olen:
 *                 return false             # <<<<<<<<<<<<<<
 *             else:
 *                 sname = chain1.get_name()
 */
        __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
        goto __pyx_L0;

        /* "plastid/genomics/roitools.pyx":496
 *             if slen < olen:
 *                 return true
 *             elif slen > olen:             # <<<<<<<<<<<<<<
 *                 return false
 *             else:
 */
      }

      /* "plastid/genomics/roitools.pyx":499
 *                 return false
 *             else:
 *                 sname = chain1.get_name()             # <<<<<<<<<<<<<<
 *                 oname = chain2.get_name()
 *                 if sname < oname:
 */
      /*else*/ {
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chain1), __pyx_n_s_get_name); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        if (__pyx_t_1) {
          __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else {
          __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(PyString_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_sname = ((PyObject*)__pyx_t_6);
        __pyx_t_6 = 0;

        /* "plastid/genomics/roitools.pyx":500
 *             else:
 *                 sname = chain1.get_name()
 *                 oname = chain2.get_name()             # <<<<<<<<<<<<<<
 *                 if sname < oname:
 *                     return true
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_chain2), __pyx_n_s_get_name); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        if (__pyx_t_1) {
          __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else {
          __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(PyString_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_v_oname = ((PyObject*)__pyx_t_6);
        __pyx_t_6 = 0;

        /* "plastid/genomics/roitools.pyx":501
 *                 sname = chain1.get_name()
 *                 oname = chain2.get_name()
 *                 if sname < oname:             # <<<<<<<<<<<<<<
 *                     return true
 *                 else:
 */
        __pyx_t_6 = PyObject_RichCompare(__pyx_v_sname, __pyx_v_oname, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_2) {

          /* "plastid/genomics/roitools.pyx":502
 *                 oname = chain2.get_name()
 *                 if sname < oname:
 *                     return true             # <<<<<<<<<<<<<<
 *                 else:
 *                     return false
 */
          __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
          goto __pyx_L0;

          /* "plastid/genomics/roitools.pyx":501
 *                 sname = chain1.get_name()
 *                 oname = chain2.get_name()
 *                 if sname < oname:             # <<<<<<<<<<<<<<
 *                     return true
 *                 else:
 */
        }

        /* "plastid/genomics/roitools.pyx":504
 *                     return true
 *                 else:
 *                     return false             # <<<<<<<<<<<<<<
 *     elif cmpval == LEQ:
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 */
        /*else*/ {
          __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
          goto __pyx_L0;
        }
      }
    }

    /* "plastid/genomics/roitools.pyx":486
 *     elif cmpval == NEQ:
 *         return true if chain_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:             # <<<<<<<<<<<<<<
 *         if sspan < ospan:
 *             return true
 */
    break;

    /* "plastid/genomics/roitools.pyx":505
 *                 else:
 *                     return false
 *     elif cmpval == LEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 */
    case 1:

    /* "plastid/genomics/roitools.pyx":506
 *                     return false
 *     elif cmpval == LEQ:
 *         return true if chain_richcmp(chain1,chain2,LT) == true \             # <<<<<<<<<<<<<<
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 */
    __pyx_t_8 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(__pyx_v_chain1, __pyx_v_chain2, 0); if (unlikely(__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":507
 *     elif cmpval == LEQ:
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \             # <<<<<<<<<<<<<<
 *                     else false
 *     elif cmpval == GT:
 */
    __pyx_t_4 = ((__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_8 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(__pyx_v_chain1, __pyx_v_chain2, 2); if (unlikely(__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":508
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false             # <<<<<<<<<<<<<<
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)
 */
    __pyx_t_4 = ((__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":506
 *                     return false
 *     elif cmpval == LEQ:
 *         return true if chain_richcmp(chain1,chain2,LT) == true \             # <<<<<<<<<<<<<<
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 */
      __pyx_t_7 = __pyx_e_7plastid_8genomics_8c_common_true;
    } else {

      /* "plastid/genomics/roitools.pyx":508
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false             # <<<<<<<<<<<<<<
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)
 */
      __pyx_t_7 = __pyx_e_7plastid_8genomics_8c_common_false;
    }
    __pyx_r = __pyx_t_7;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":505
 *                 else:
 *                     return false
 *     elif cmpval == LEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 */
    break;

    /* "plastid/genomics/roitools.pyx":509
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 *     elif cmpval == GT:             # <<<<<<<<<<<<<<
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:
 */
    case 4:

    /* "plastid/genomics/roitools.pyx":510
 *                     else false
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)             # <<<<<<<<<<<<<<
 *     elif cmpval == GEQ:
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 */
    __pyx_t_7 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(__pyx_v_chain2, __pyx_v_chain1, 0); if (unlikely(__pyx_t_7 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_7;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":509
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 *     elif cmpval == GT:             # <<<<<<<<<<<<<<
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:
 */
    break;

    /* "plastid/genomics/roitools.pyx":511
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 */
    case 5:

    /* "plastid/genomics/roitools.pyx":512
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:
 *         return true if chain_richcmp(chain2,chain1,LT) == true \             # <<<<<<<<<<<<<<
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 */
    __pyx_t_8 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(__pyx_v_chain2, __pyx_v_chain1, 0); if (unlikely(__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":513
 *     elif cmpval == GEQ:
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \             # <<<<<<<<<<<<<<
 *                     else false
 *     else:
 */
    __pyx_t_4 = ((__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_8 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(__pyx_v_chain1, __pyx_v_chain2, 2); if (unlikely(__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":514
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError("This operation is not defined for SegmentChains.")
 */
    __pyx_t_4 = ((__pyx_t_8 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L15_bool_binop_done:;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":512
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:
 *         return true if chain_richcmp(chain2,chain1,LT) == true \             # <<<<<<<<<<<<<<
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 */
      __pyx_t_7 = __pyx_e_7plastid_8genomics_8c_common_true;
    } else {

      /* "plastid/genomics/roitools.pyx":514
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 *                     else false             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError("This operation is not defined for SegmentChains.")
 */
      __pyx_t_7 = __pyx_e_7plastid_8genomics_8c_common_false;
    }
    __pyx_r = __pyx_t_7;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":511
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or chain_richcmp(chain1,chain2,EQ) == true \
 */
    break;
    default:

    /* "plastid/genomics/roitools.pyx":516
 *                     else false
 *     else:
 *         raise ValueError("This operation is not defined for SegmentChains.")             # <<<<<<<<<<<<<<
 * 
 * cdef ExBool transcript_richcmp(Transcript chain1, Transcript chain2, int cmpval) except bool_exception:
 */
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  /* "plastid/genomics/roitools.pyx":438
 *     return True
 * 
 * cdef ExBool chain_richcmp(SegmentChain chain1, SegmentChain chain2, int cmpval) except bool_exception:             # <<<<<<<<<<<<<<
 *     """Helper method for rich comparisons (==, !=, <, >, <=, >=) of |SegmentChains|
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.chain_richcmp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_bool_exception;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sspan);
  __Pyx_XDECREF(__pyx_v_ospan);
  __Pyx_XDECREF(__pyx_v_sname);
  __Pyx_XDECREF(__pyx_v_oname);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":518
 *         raise ValueError("This operation is not defined for SegmentChains.")
 * 
 * cdef ExBool transcript_richcmp(Transcript chain1, Transcript chain2, int cmpval) except bool_exception:             # <<<<<<<<<<<<<<
 *     """Helper method for rich comparisons (==, !=, <, >, <=, >=) of |Transcripts|
 * 
 */

static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_transcript_richcmp(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_chain1, struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_chain2, int __pyx_v_cmpval) {
  CYTHON_UNUSED PyObject *__pyx_v_sspan = 0;
  CYTHON_UNUSED PyObject *__pyx_v_ospan = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("transcript_richcmp", 0);

  /* "plastid/genomics/roitools.pyx":550
 *     """
 *     cdef:
 *         sspan = chain1.spanning_segment             # <<<<<<<<<<<<<<
 *         ospan = chain2.spanning_segment
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_chain1->__pyx_base.spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_sspan = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":551
 *     cdef:
 *         sspan = chain1.spanning_segment
 *         ospan = chain2.spanning_segment             # <<<<<<<<<<<<<<
 * 
 *     if cmpval == EQ:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_chain2->__pyx_base.spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ospan = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":553
 *         ospan = chain2.spanning_segment
 * 
 *     if cmpval == EQ:             # <<<<<<<<<<<<<<
 *         if chain_richcmp(chain1,chain2,cmpval) == true and \
 *                (
 */
  switch (__pyx_v_cmpval) {
    case 2:

    /* "plastid/genomics/roitools.pyx":554
 * 
 *     if cmpval == EQ:
 *         if chain_richcmp(chain1,chain2,cmpval) == true and \             # <<<<<<<<<<<<<<
 *                (
 *                    (chain1.cds_genome_start is None and chain2.cds_genome_start is None and\
 */
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain1), ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), __pyx_v_cmpval); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = ((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }

    /* "plastid/genomics/roitools.pyx":556
 *         if chain_richcmp(chain1,chain2,cmpval) == true and \
 *                (
 *                    (chain1.cds_genome_start is None and chain2.cds_genome_start is None and\             # <<<<<<<<<<<<<<
 *                     chain1.cds_genome_end is None and chain2.cds_genome_end is None) or\
 *                    (chain1.cds_genome_start == chain2.cds_genome_start and\
 */
    __pyx_t_4 = (__pyx_v_chain1->cds_genome_start == Py_None);
    __pyx_t_5 = (__pyx_t_4 != 0);
    if (!__pyx_t_5) {
      goto __pyx_L6_next_or;
    } else {
    }
    __pyx_t_5 = (__pyx_v_chain2->cds_genome_start == Py_None);
    __pyx_t_4 = (__pyx_t_5 != 0);
    if (!__pyx_t_4) {
      goto __pyx_L6_next_or;
    } else {
    }

    /* "plastid/genomics/roitools.pyx":557
 *                (
 *                    (chain1.cds_genome_start is None and chain2.cds_genome_start is None and\
 *                     chain1.cds_genome_end is None and chain2.cds_genome_end is None) or\             # <<<<<<<<<<<<<<
 *                    (chain1.cds_genome_start == chain2.cds_genome_start and\
 *                     chain1.cds_genome_end == chain2.cds_genome_end)
 */
    __pyx_t_4 = (__pyx_v_chain1->cds_genome_end == Py_None);
    __pyx_t_5 = (__pyx_t_4 != 0);
    if (!__pyx_t_5) {
      goto __pyx_L6_next_or;
    } else {
    }
    __pyx_t_5 = (__pyx_v_chain2->cds_genome_end == Py_None);
    __pyx_t_4 = (__pyx_t_5 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_L6_next_or:;

    /* "plastid/genomics/roitools.pyx":558
 *                    (chain1.cds_genome_start is None and chain2.cds_genome_start is None and\
 *                     chain1.cds_genome_end is None and chain2.cds_genome_end is None) or\
 *                    (chain1.cds_genome_start == chain2.cds_genome_start and\             # <<<<<<<<<<<<<<
 *                     chain1.cds_genome_end == chain2.cds_genome_end)
 *                 ):
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_chain1->cds_genome_start, __pyx_v_chain2->cds_genome_start, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }

    /* "plastid/genomics/roitools.pyx":559
 *                     chain1.cds_genome_end is None and chain2.cds_genome_end is None) or\
 *                    (chain1.cds_genome_start == chain2.cds_genome_start and\
 *                     chain1.cds_genome_end == chain2.cds_genome_end)             # <<<<<<<<<<<<<<
 *                 ):
 *                    return true
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_chain1->cds_genome_end, __pyx_v_chain2->cds_genome_end, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = __pyx_t_4;
    __pyx_L4_bool_binop_done:;

    /* "plastid/genomics/roitools.pyx":554
 * 
 *     if cmpval == EQ:
 *         if chain_richcmp(chain1,chain2,cmpval) == true and \             # <<<<<<<<<<<<<<
 *                (
 *                    (chain1.cds_genome_start is None and chain2.cds_genome_start is None and\
 */
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":561
 *                     chain1.cds_genome_end == chain2.cds_genome_end)
 *                 ):
 *                    return true             # <<<<<<<<<<<<<<
 *         return false
 *     elif cmpval == NEQ:
 */
      __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":554
 * 
 *     if cmpval == EQ:
 *         if chain_richcmp(chain1,chain2,cmpval) == true and \             # <<<<<<<<<<<<<<
 *                (
 *                    (chain1.cds_genome_start is None and chain2.cds_genome_start is None and\
 */
    }

    /* "plastid/genomics/roitools.pyx":562
 *                 ):
 *                    return true
 *         return false             # <<<<<<<<<<<<<<
 *     elif cmpval == NEQ:
 *         return true if transcript_richcmp(chain1,chain2,EQ) == false else true
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":553
 *         ospan = chain2.spanning_segment
 * 
 *     if cmpval == EQ:             # <<<<<<<<<<<<<<
 *         if chain_richcmp(chain1,chain2,cmpval) == true and \
 *                (
 */
    break;

    /* "plastid/genomics/roitools.pyx":563
 *                    return true
 *         return false
 *     elif cmpval == NEQ:             # <<<<<<<<<<<<<<
 *         return true if transcript_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:
 */
    case 3:

    /* "plastid/genomics/roitools.pyx":564
 *         return false
 *     elif cmpval == NEQ:
 *         return true if transcript_richcmp(chain1,chain2,EQ) == false else true             # <<<<<<<<<<<<<<
 *     elif cmpval == LT:
 *         return chain_richcmp(chain1,chain2,cmpval)
 */
    __pyx_t_6 = __pyx_f_7plastid_8genomics_8roitools_transcript_richcmp(__pyx_v_chain1, __pyx_v_chain2, 2); if (unlikely(__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (((__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_false) != 0)) {
      __pyx_t_3 = __pyx_e_7plastid_8genomics_8c_common_true;
    } else {
      __pyx_t_3 = __pyx_e_7plastid_8genomics_8c_common_true;
    }
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":563
 *                    return true
 *         return false
 *     elif cmpval == NEQ:             # <<<<<<<<<<<<<<
 *         return true if transcript_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:
 */
    break;

    /* "plastid/genomics/roitools.pyx":565
 *     elif cmpval == NEQ:
 *         return true if transcript_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:             # <<<<<<<<<<<<<<
 *         return chain_richcmp(chain1,chain2,cmpval)
 *     elif cmpval == LEQ:
 */
    case 0:

    /* "plastid/genomics/roitools.pyx":566
 *         return true if transcript_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:
 *         return chain_richcmp(chain1,chain2,cmpval)             # <<<<<<<<<<<<<<
 *     elif cmpval == LEQ:
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 */
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain1), ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), __pyx_v_cmpval); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":565
 *     elif cmpval == NEQ:
 *         return true if transcript_richcmp(chain1,chain2,EQ) == false else true
 *     elif cmpval == LT:             # <<<<<<<<<<<<<<
 *         return chain_richcmp(chain1,chain2,cmpval)
 *     elif cmpval == LEQ:
 */
    break;

    /* "plastid/genomics/roitools.pyx":567
 *     elif cmpval == LT:
 *         return chain_richcmp(chain1,chain2,cmpval)
 *     elif cmpval == LEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \
 */
    case 1:

    /* "plastid/genomics/roitools.pyx":568
 *         return chain_richcmp(chain1,chain2,cmpval)
 *     elif cmpval == LEQ:
 *         return true if chain_richcmp(chain1,chain2,LT) == true \             # <<<<<<<<<<<<<<
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 */
    __pyx_t_6 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain1), ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), 0); if (unlikely(__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":569
 *     elif cmpval == LEQ:
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \             # <<<<<<<<<<<<<<
 *                     else false
 *     elif cmpval == GT:
 */
    __pyx_t_4 = ((__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_6 = __pyx_f_7plastid_8genomics_8roitools_transcript_richcmp(__pyx_v_chain1, __pyx_v_chain2, 2); if (unlikely(__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":570
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \
 *                     else false             # <<<<<<<<<<<<<<
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)
 */
    __pyx_t_4 = ((__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":568
 *         return chain_richcmp(chain1,chain2,cmpval)
 *     elif cmpval == LEQ:
 *         return true if chain_richcmp(chain1,chain2,LT) == true \             # <<<<<<<<<<<<<<
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 */
      __pyx_t_3 = __pyx_e_7plastid_8genomics_8c_common_true;
    } else {

      /* "plastid/genomics/roitools.pyx":570
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \
 *                     else false             # <<<<<<<<<<<<<<
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)
 */
      __pyx_t_3 = __pyx_e_7plastid_8genomics_8c_common_false;
    }
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":567
 *     elif cmpval == LT:
 *         return chain_richcmp(chain1,chain2,cmpval)
 *     elif cmpval == LEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain1,chain2,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \
 */
    break;

    /* "plastid/genomics/roitools.pyx":571
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 *     elif cmpval == GT:             # <<<<<<<<<<<<<<
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:
 */
    case 4:

    /* "plastid/genomics/roitools.pyx":572
 *                     else false
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)             # <<<<<<<<<<<<<<
 *     elif cmpval == GEQ:
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 */
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain1), 0); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":571
 *                     or transcript_richcmp(chain1,chain2,EQ) == true \
 *                     else false
 *     elif cmpval == GT:             # <<<<<<<<<<<<<<
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:
 */
    break;

    /* "plastid/genomics/roitools.pyx":573
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true\
 */
    case 5:

    /* "plastid/genomics/roitools.pyx":574
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:
 *         return true if chain_richcmp(chain2,chain1,LT) == true \             # <<<<<<<<<<<<<<
 *                     or transcript_richcmp(chain1,chain2,EQ) == true\
 *                     else false
 */
    __pyx_t_6 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain1), 0); if (unlikely(__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":575
 *     elif cmpval == GEQ:
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true\             # <<<<<<<<<<<<<<
 *                     else false
 *     else:
 */
    __pyx_t_4 = ((__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L13_bool_binop_done;
    }
    __pyx_t_6 = __pyx_f_7plastid_8genomics_8roitools_transcript_richcmp(__pyx_v_chain1, __pyx_v_chain2, 2); if (unlikely(__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":576
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true\
 *                     else false             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError("This operation is not defined for Transcripts.")
 */
    __pyx_t_4 = ((__pyx_t_6 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L13_bool_binop_done:;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":574
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:
 *         return true if chain_richcmp(chain2,chain1,LT) == true \             # <<<<<<<<<<<<<<
 *                     or transcript_richcmp(chain1,chain2,EQ) == true\
 *                     else false
 */
      __pyx_t_3 = __pyx_e_7plastid_8genomics_8c_common_true;
    } else {

      /* "plastid/genomics/roitools.pyx":576
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true\
 *                     else false             # <<<<<<<<<<<<<<
 *     else:
 *         raise ValueError("This operation is not defined for Transcripts.")
 */
      __pyx_t_3 = __pyx_e_7plastid_8genomics_8c_common_false;
    }
    __pyx_r = __pyx_t_3;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":573
 *     elif cmpval == GT:
 *         return chain_richcmp(chain2,chain1,LT)
 *     elif cmpval == GEQ:             # <<<<<<<<<<<<<<
 *         return true if chain_richcmp(chain2,chain1,LT) == true \
 *                     or transcript_richcmp(chain1,chain2,EQ) == true\
 */
    break;
    default:

    /* "plastid/genomics/roitools.pyx":578
 *                     else false
 *     else:
 *         raise ValueError("This operation is not defined for Transcripts.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __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 = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  /* "plastid/genomics/roitools.pyx":518
 *         raise ValueError("This operation is not defined for SegmentChains.")
 * 
 * cdef ExBool transcript_richcmp(Transcript chain1, Transcript chain2, int cmpval) except bool_exception:             # <<<<<<<<<<<<<<
 *     """Helper method for rich comparisons (==, !=, <, >, <=, >=) of |Transcripts|
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.transcript_richcmp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_bool_exception;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sspan);
  __Pyx_XDECREF(__pyx_v_ospan);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":656
 *         coding regions, UTRs, et c
 *     """
 *     def __cinit__(self, str chrom, long start, long end, str strand):             # <<<<<<<<<<<<<<
 *         """Create a |GenomicSegment|
 * 
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_chrom = 0;
  long __pyx_v_start;
  long __pyx_v_end;
  PyObject *__pyx_v_strand = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_chrom,&__pyx_n_s_start,&__pyx_n_s_end,&__pyx_n_s_strand,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_chrom)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_strand)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __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_chrom = ((PyObject*)values[0]);
    __pyx_v_start = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v_start == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_end = __Pyx_PyInt_As_long(values[2]); if (unlikely((__pyx_v_end == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_strand = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chrom), (&PyString_Type), 1, "chrom", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_strand), (&PyString_Type), 1, "strand", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment___cinit__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self), __pyx_v_chrom, __pyx_v_start, __pyx_v_end, __pyx_v_strand);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment___cinit__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, PyObject *__pyx_v_chrom, long __pyx_v_start, long __pyx_v_end, PyObject *__pyx_v_strand) {
  PyObject *__pyx_v_my_chrom = NULL;
  int __pyx_r;
  __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("__cinit__", 0);

  /* "plastid/genomics/roitools.pyx":674
 *             Chromosome strand (`'+'`, `'-'`, or `'.'`)
 *         """
 *         if end < start:             # <<<<<<<<<<<<<<
 *             raise ValueError("GenomicSegment: start coordinate (%s) must be >= end (%s)." % (start,end))
 *         my_chrom = chrom
 */
  __pyx_t_1 = ((__pyx_v_end < __pyx_v_start) != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":675
 *         """
 *         if end < start:
 *             raise ValueError("GenomicSegment: start coordinate (%s) must be >= end (%s)." % (start,end))             # <<<<<<<<<<<<<<
 *         my_chrom = chrom
 *         self.chrom  = my_chrom
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __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 = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_GenomicSegment_start_coordinate, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __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 = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__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 = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":674
 *             Chromosome strand (`'+'`, `'-'`, or `'.'`)
 *         """
 *         if end < start:             # <<<<<<<<<<<<<<
 *             raise ValueError("GenomicSegment: start coordinate (%s) must be >= end (%s)." % (start,end))
 *         my_chrom = chrom
 */
  }

  /* "plastid/genomics/roitools.pyx":676
 *         if end < start:
 *             raise ValueError("GenomicSegment: start coordinate (%s) must be >= end (%s)." % (start,end))
 *         my_chrom = chrom             # <<<<<<<<<<<<<<
 *         self.chrom  = my_chrom
 *         self.start  = start
 */
  __Pyx_INCREF(__pyx_v_chrom);
  __pyx_v_my_chrom = __pyx_v_chrom;

  /* "plastid/genomics/roitools.pyx":677
 *             raise ValueError("GenomicSegment: start coordinate (%s) must be >= end (%s)." % (start,end))
 *         my_chrom = chrom
 *         self.chrom  = my_chrom             # <<<<<<<<<<<<<<
 *         self.start  = start
 *         self.end    = end
 */
  if (!(likely(PyString_CheckExact(__pyx_v_my_chrom))||((__pyx_v_my_chrom) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_my_chrom)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __pyx_v_my_chrom;
  __Pyx_INCREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->chrom);
  __Pyx_DECREF(__pyx_v_self->chrom);
  __pyx_v_self->chrom = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "plastid/genomics/roitools.pyx":678
 *         my_chrom = chrom
 *         self.chrom  = my_chrom
 *         self.start  = start             # <<<<<<<<<<<<<<
 *         self.end    = end
 *         self.c_strand = str_to_strand(strand)
 */
  __pyx_v_self->start = __pyx_v_start;

  /* "plastid/genomics/roitools.pyx":679
 *         self.chrom  = my_chrom
 *         self.start  = start
 *         self.end    = end             # <<<<<<<<<<<<<<
 *         self.c_strand = str_to_strand(strand)
 * 
 */
  __pyx_v_self->end = __pyx_v_end;

  /* "plastid/genomics/roitools.pyx":680
 *         self.start  = start
 *         self.end    = end
 *         self.c_strand = str_to_strand(strand)             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self): # enables pickling
 */
  __pyx_v_self->c_strand = __pyx_f_7plastid_8genomics_8roitools_str_to_strand(__pyx_v_strand);

  /* "plastid/genomics/roitools.pyx":656
 *         coding regions, UTRs, et c
 *     """
 *     def __cinit__(self, str chrom, long start, long end, str strand):             # <<<<<<<<<<<<<<
 *         """Create a |GenomicSegment|
 * 
 */

  /* function exit code */
  __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_AddTraceback("plastid.genomics.roitools.GenomicSegment.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_my_chrom);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":682
 *         self.c_strand = str_to_strand(strand)
 * 
 *     def __reduce__(self): # enables pickling             # <<<<<<<<<<<<<<
 *         return (GenomicSegment,(self.chrom,self.start,self.end,self.strand))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_3__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_2__reduce__[] = "GenomicSegment.__reduce__(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_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_7plastid_8genomics_8roitools_14GenomicSegment_2__reduce__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_2__reduce__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__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);

  /* "plastid/genomics/roitools.pyx":683
 * 
 *     def __reduce__(self): # enables pickling
 *         return (GenomicSegment,(self.chrom,self.start,self.end,self.strand))             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->end); 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_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->chrom);
  __Pyx_GIVEREF(__pyx_v_self->chrom);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->chrom);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3);
  __pyx_t_1 = 0;
  __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 = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment));
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":682
 *         self.c_strand = str_to_strand(strand)
 * 
 *     def __reduce__(self): # enables pickling             # <<<<<<<<<<<<<<
 *         return (GenomicSegment,(self.chrom,self.start,self.end,self.strand))
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.GenomicSegment.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":685
 *         return (GenomicSegment,(self.chrom,self.start,self.end,self.strand))
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s %s:%s-%s strand='%s'>" % ("GenomicSegment",
 *                                               self.chrom,
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_4__repr__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_4__repr__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__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("__repr__", 0);

  /* "plastid/genomics/roitools.pyx":686
 * 
 *     def __repr__(self):
 *         return "<%s %s:%s-%s strand='%s'>" % ("GenomicSegment",             # <<<<<<<<<<<<<<
 *                                               self.chrom,
 *                                               self.start,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "plastid/genomics/roitools.pyx":688
 *         return "<%s %s:%s-%s strand='%s'>" % ("GenomicSegment",
 *                                               self.chrom,
 *                                               self.start,             # <<<<<<<<<<<<<<
 *                                               self.end,
 *                                               self.strand)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":689
 *                                               self.chrom,
 *                                               self.start,
 *                                               self.end,             # <<<<<<<<<<<<<<
 *                                               self.strand)
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->end); 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);

  /* "plastid/genomics/roitools.pyx":690
 *                                               self.start,
 *                                               self.end,
 *                                               self.strand)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "plastid/genomics/roitools.pyx":686
 * 
 *     def __repr__(self):
 *         return "<%s %s:%s-%s strand='%s'>" % ("GenomicSegment",             # <<<<<<<<<<<<<<
 *                                               self.chrom,
 *                                               self.start,
 */
  __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_GenomicSegment);
  __Pyx_GIVEREF(__pyx_n_s_GenomicSegment);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_GenomicSegment);
  __Pyx_INCREF(__pyx_v_self->chrom);
  __Pyx_GIVEREF(__pyx_v_self->chrom);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->chrom);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_s_strand_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":685
 *         return (GenomicSegment,(self.chrom,self.start,self.end,self.strand))
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s %s:%s-%s strand='%s'>" % ("GenomicSegment",
 *                                               self.chrom,
 */

  /* function exit code */
  __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("plastid.genomics.roitools.GenomicSegment.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":692
 *                                               self.strand)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s:%s-%s(%s)" % (self.chrom, self.start, self.end, self.strand)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_7__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_7__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_6__str__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_6__str__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__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("__str__", 0);

  /* "plastid/genomics/roitools.pyx":693
 * 
 *     def __str__(self):
 *         return "%s:%s-%s(%s)" % (self.chrom, self.start, self.end, self.strand)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->chrom);
  __Pyx_GIVEREF(__pyx_v_self->chrom);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->chrom);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":692
 *                                               self.strand)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "%s:%s-%s(%s)" % (self.chrom, self.start, self.end, self.strand)
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.GenomicSegment.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":696
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Construct a |GenomicSegment| from its ``str()`` representation
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_9from_str(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_8from_str[] = "GenomicSegment.from_str(str inp)\nConstruct a |GenomicSegment| from its ``str()`` representation\n        \n        Parameters\n        ----------\n        inp : str\n            String representation of |GenomicSegment| as `chrom:start-end(strand)`\n            where `start` and `end` are in 0-indexed, half-open coordinates\n        \n        Returns\n        -------\n        |GenomicSegment|\n        ";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_14GenomicSegment_9from_str = {"from_str", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_9from_str, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_8from_str};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_9from_str(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_str (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inp,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_inp)) != 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, "from_str") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __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_inp = ((PyObject*)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_str", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.from_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_inp), (&PyString_Type), 1, "inp", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_8from_str(__pyx_v_inp);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_8from_str(PyObject *__pyx_v_inp) {
  long __pyx_v_start;
  long __pyx_v_end;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_strand = 0;
  PyObject *__pyx_v_s_start = 0;
  PyObject *__pyx_v_s_end = 0;
  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)(PyObject *);
  long __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_str", 0);

  /* "plastid/genomics/roitools.pyx":712
 *             long start, end
 *             str chrom, strand, s_start, s_end
 *         chrom, s_start, s_end, strand = segpat.search(inp).groups()             # <<<<<<<<<<<<<<
 *         start = long(s_start)
 *         end   = long(s_end)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_segpat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_search); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_inp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_inp);
    __Pyx_GIVEREF(__pyx_v_inp);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_inp);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_groups); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  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 != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_2,&__pyx_t_5,&__pyx_t_3};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_2,&__pyx_t_5,&__pyx_t_3};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_chrom = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_v_s_start = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_s_end = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_strand = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "plastid/genomics/roitools.pyx":713
 *             str chrom, strand, s_start, s_end
 *         chrom, s_start, s_end, strand = segpat.search(inp).groups()
 *         start = long(s_start)             # <<<<<<<<<<<<<<
 *         end   = long(s_end)
 *         return GenomicSegment(chrom,start,end,strand)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_s_start);
  __Pyx_GIVEREF(__pyx_v_s_start);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s_start);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyLong_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __Pyx_PyInt_As_long(__pyx_t_3); if (unlikely((__pyx_t_8 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_start = __pyx_t_8;

  /* "plastid/genomics/roitools.pyx":714
 *         chrom, s_start, s_end, strand = segpat.search(inp).groups()
 *         start = long(s_start)
 *         end   = long(s_end)             # <<<<<<<<<<<<<<
 *         return GenomicSegment(chrom,start,end,strand)
 * 
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_s_end);
  __Pyx_GIVEREF(__pyx_v_s_end);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s_end);
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyLong_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_8 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_8 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_end = __pyx_t_8;

  /* "plastid/genomics/roitools.pyx":715
 *         start = long(s_start)
 *         end   = long(s_end)
 *         return GenomicSegment(chrom,start,end,strand)             # <<<<<<<<<<<<<<
 * 
 *     def __copy__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_v_chrom);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_strand);
  __Pyx_GIVEREF(__pyx_v_strand);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_strand);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":696
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Construct a |GenomicSegment| from its ``str()`` representation
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.GenomicSegment.from_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_strand);
  __Pyx_XDECREF(__pyx_v_s_start);
  __Pyx_XDECREF(__pyx_v_s_end);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":717
 *         return GenomicSegment(chrom,start,end,strand)
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         cdef str newchrom, newstrand
 *         cdef long newstart, newend
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_11__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_10__copy__[] = "GenomicSegment.__copy__(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_11__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__copy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_10__copy__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_10__copy__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self) {
  PyObject *__pyx_v_newchrom = 0;
  PyObject *__pyx_v_newstrand = 0;
  long __pyx_v_newstart;
  long __pyx_v_newend;
  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;
  long __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__copy__", 0);

  /* "plastid/genomics/roitools.pyx":720
 *         cdef str newchrom, newstrand
 *         cdef long newstart, newend
 *         newchrom = copy.copy(self.chrom)             # <<<<<<<<<<<<<<
 *         newstrand = self.strand
 *         newstart = self.start
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->chrom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->chrom);
    __Pyx_GIVEREF(__pyx_v_self->chrom);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->chrom);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_newchrom = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":721
 *         cdef long newstart, newend
 *         newchrom = copy.copy(self.chrom)
 *         newstrand = self.strand             # <<<<<<<<<<<<<<
 *         newstart = self.start
 *         newend = self.end
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_newstrand = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":722
 *         newchrom = copy.copy(self.chrom)
 *         newstrand = self.strand
 *         newstart = self.start             # <<<<<<<<<<<<<<
 *         newend = self.end
 *         return GenomicSegment(newchrom,newstart,newend,newstrand)
 */
  __pyx_t_5 = __pyx_v_self->start;
  __pyx_v_newstart = __pyx_t_5;

  /* "plastid/genomics/roitools.pyx":723
 *         newstrand = self.strand
 *         newstart = self.start
 *         newend = self.end             # <<<<<<<<<<<<<<
 *         return GenomicSegment(newchrom,newstart,newend,newstrand)
 * 
 */
  __pyx_t_5 = __pyx_v_self->end;
  __pyx_v_newend = __pyx_t_5;

  /* "plastid/genomics/roitools.pyx":724
 *         newstart = self.start
 *         newend = self.end
 *         return GenomicSegment(newchrom,newstart,newend,newstrand)             # <<<<<<<<<<<<<<
 * 
 *     def __deepcopy__(self,memo):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_newstart); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_newend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_newchrom);
  __Pyx_GIVEREF(__pyx_v_newchrom);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_newchrom);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_newstrand);
  __Pyx_GIVEREF(__pyx_v_newstrand);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_newstrand);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":717
 *         return GenomicSegment(chrom,start,end,strand)
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         cdef str newchrom, newstrand
 *         cdef long newstart, newend
 */

  /* function exit code */
  __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("plastid.genomics.roitools.GenomicSegment.__copy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_newchrom);
  __Pyx_XDECREF(__pyx_v_newstrand);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":726
 *         return GenomicSegment(newchrom,newstart,newend,newstrand)
 * 
 *     def __deepcopy__(self,memo):             # <<<<<<<<<<<<<<
 *         return self.__copy__()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_13__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_12__deepcopy__[] = "GenomicSegment.__deepcopy__(self, memo)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_13__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__deepcopy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_12__deepcopy__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self), ((PyObject *)__pyx_v_memo));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_12__deepcopy__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo) {
  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("__deepcopy__", 0);

  /* "plastid/genomics/roitools.pyx":727
 * 
 *     def __deepcopy__(self,memo):
 *         return self.__copy__()             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_copy_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":726
 *         return GenomicSegment(newchrom,newstart,newend,newstrand)
 * 
 *     def __deepcopy__(self,memo):             # <<<<<<<<<<<<<<
 *         return self.__copy__()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.__deepcopy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":729
 *         return self.__copy__()
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         """Return length, in nucleotides, of |GenomicSegment|"""
 *         cdef long len
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_15__len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_14__len__[] = "Return length, in nucleotides, of |GenomicSegment|";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7plastid_8genomics_8roitools_14GenomicSegment_14__len__;
#endif
static Py_ssize_t __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_15__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_14__len__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_14__len__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self) {
  long __pyx_v_len;
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "plastid/genomics/roitools.pyx":732
 *         """Return length, in nucleotides, of |GenomicSegment|"""
 *         cdef long len
 *         len = self.end - self.start             # <<<<<<<<<<<<<<
 *         return len
 * 
 */
  __pyx_v_len = (__pyx_v_self->end - __pyx_v_self->start);

  /* "plastid/genomics/roitools.pyx":733
 *         cdef long len
 *         len = self.end - self.start
 *         return len             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(self,GenomicSegment other, int cmptype):
 */
  __pyx_r = __pyx_v_len;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":729
 *         return self.__copy__()
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         """Return length, in nucleotides, of |GenomicSegment|"""
 *         cdef long len
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":735
 *         return len
 * 
 *     def __richcmp__(self,GenomicSegment other, int cmptype):             # <<<<<<<<<<<<<<
 *         if other is None or not isinstance(other,GenomicSegment):
 *             return False
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_17__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmptype); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_17__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmptype) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_16__richcmp__(((PyObject *)__pyx_v_self), ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_other), ((int)__pyx_v_cmptype));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_16__richcmp__(PyObject *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_v_cmptype) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__richcmp__", 0);

  /* "plastid/genomics/roitools.pyx":736
 * 
 *     def __richcmp__(self,GenomicSegment other, int cmptype):
 *         if other is None or not isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_other) == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_TypeCheck(((PyObject *)__pyx_v_other), __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_2 = ((!(__pyx_t_3 != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":737
 *     def __richcmp__(self,GenomicSegment other, int cmptype):
 *         if other is None or not isinstance(other,GenomicSegment):
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         return self._cmp_helper(other,cmptype)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":736
 * 
 *     def __richcmp__(self,GenomicSegment other, int cmptype):
 *         if other is None or not isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":739
 *             return False
 * 
 *         return self._cmp_helper(other,cmptype)             # <<<<<<<<<<<<<<
 * 
 *     # TODO: suspend type check via decorator, since we have already done this
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cmp_helper); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_cmptype); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_8 = 1;
    }
  }
  __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  if (__pyx_t_7) {
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
  }
  __Pyx_INCREF(((PyObject *)__pyx_v_other));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
  PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, ((PyObject *)__pyx_v_other));
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":735
 *         return len
 * 
 *     def __richcmp__(self,GenomicSegment other, int cmptype):             # <<<<<<<<<<<<<<
 *         if other is None or not isinstance(other,GenomicSegment):
 *             return False
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":742
 * 
 *     # TODO: suspend type check via decorator, since we have already done this
 *     cpdef bint _cmp_helper(self,GenomicSegment other,int cmptype):             # <<<<<<<<<<<<<<
 *         nonecheck(other,"GenomicSegment eq/neq","other")
 *         schrom = self.chrom
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_19_cmp_helper(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_7plastid_8genomics_8roitools_14GenomicSegment__cmp_helper(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_v_cmptype, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_schrom = NULL;
  PyObject *__pyx_v_ochrom = NULL;
  long __pyx_v_sstart;
  long __pyx_v_ostart;
  long __pyx_v_send;
  long __pyx_v_oend;
  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;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  long __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_cmp_helper", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_cmp_helper); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __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_7plastid_8genomics_8roitools_14GenomicSegment_19_cmp_helper)) {
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_cmptype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_other));
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_8;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "plastid/genomics/roitools.pyx":743
 *     # TODO: suspend type check via decorator, since we have already done this
 *     cpdef bint _cmp_helper(self,GenomicSegment other,int cmptype):
 *         nonecheck(other,"GenomicSegment eq/neq","other")             # <<<<<<<<<<<<<<
 *         schrom = self.chrom
 *         ochrom = other.chrom
 */
  __pyx_f_7plastid_8genomics_8roitools_nonecheck(((PyObject *)__pyx_v_other), __pyx_kp_s_GenomicSegment_eq_neq, __pyx_n_s_other);

  /* "plastid/genomics/roitools.pyx":744
 *     cpdef bint _cmp_helper(self,GenomicSegment other,int cmptype):
 *         nonecheck(other,"GenomicSegment eq/neq","other")
 *         schrom = self.chrom             # <<<<<<<<<<<<<<
 *         ochrom = other.chrom
 *         if cmptype == EQ:
 */
  __pyx_t_1 = __pyx_v_self->chrom;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_schrom = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":745
 *         nonecheck(other,"GenomicSegment eq/neq","other")
 *         schrom = self.chrom
 *         ochrom = other.chrom             # <<<<<<<<<<<<<<
 *         if cmptype == EQ:
 *             return schrom         == ochrom and\
 */
  __pyx_t_1 = __pyx_v_other->chrom;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ochrom = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":746
 *         schrom = self.chrom
 *         ochrom = other.chrom
 *         if cmptype == EQ:             # <<<<<<<<<<<<<<
 *             return schrom         == ochrom and\
 *                    self.c_strand  == other.c_strand and\
 */
  switch (__pyx_v_cmptype) {
    case 2:

    /* "plastid/genomics/roitools.pyx":747
 *         ochrom = other.chrom
 *         if cmptype == EQ:
 *             return schrom         == ochrom and\             # <<<<<<<<<<<<<<
 *                    self.c_strand  == other.c_strand and\
 *                    self.start     == other.start and\
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_schrom, __pyx_v_ochrom, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }

    /* "plastid/genomics/roitools.pyx":748
 *         if cmptype == EQ:
 *             return schrom         == ochrom and\
 *                    self.c_strand  == other.c_strand and\             # <<<<<<<<<<<<<<
 *                    self.start     == other.start and\
 *                    self.end       == other.end
 */
    __pyx_t_9 = ((__pyx_v_self->c_strand == __pyx_v_other->c_strand) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }

    /* "plastid/genomics/roitools.pyx":749
 *             return schrom         == ochrom and\
 *                    self.c_strand  == other.c_strand and\
 *                    self.start     == other.start and\             # <<<<<<<<<<<<<<
 *                    self.end       == other.end
 *         elif cmptype == NEQ:
 */
    __pyx_t_9 = ((__pyx_v_self->start == __pyx_v_other->start) != 0);
    if (__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L3_bool_binop_done;
    }

    /* "plastid/genomics/roitools.pyx":750
 *                    self.c_strand  == other.c_strand and\
 *                    self.start     == other.start and\
 *                    self.end       == other.end             # <<<<<<<<<<<<<<
 *         elif cmptype == NEQ:
 *             return self._cmp_helper(other,EQ) == False
 */
    __pyx_t_9 = ((__pyx_v_self->end == __pyx_v_other->end) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L3_bool_binop_done:;
    __pyx_r = __pyx_t_8;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":746
 *         schrom = self.chrom
 *         ochrom = other.chrom
 *         if cmptype == EQ:             # <<<<<<<<<<<<<<
 *             return schrom         == ochrom and\
 *                    self.c_strand  == other.c_strand and\
 */
    break;

    /* "plastid/genomics/roitools.pyx":751
 *                    self.start     == other.start and\
 *                    self.end       == other.end
 *         elif cmptype == NEQ:             # <<<<<<<<<<<<<<
 *             return self._cmp_helper(other,EQ) == False
 *         elif cmptype == LT:
 */
    case 3:

    /* "plastid/genomics/roitools.pyx":752
 *                    self.end       == other.end
 *         elif cmptype == NEQ:
 *             return self._cmp_helper(other,EQ) == False             # <<<<<<<<<<<<<<
 *         elif cmptype == LT:
 *             if schrom < ochrom:
 */
    __pyx_r = (((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self->__pyx_vtab)->_cmp_helper(__pyx_v_self, __pyx_v_other, 2, 0) == 0);
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":751
 *                    self.start     == other.start and\
 *                    self.end       == other.end
 *         elif cmptype == NEQ:             # <<<<<<<<<<<<<<
 *             return self._cmp_helper(other,EQ) == False
 *         elif cmptype == LT:
 */
    break;

    /* "plastid/genomics/roitools.pyx":753
 *         elif cmptype == NEQ:
 *             return self._cmp_helper(other,EQ) == False
 *         elif cmptype == LT:             # <<<<<<<<<<<<<<
 *             if schrom < ochrom:
 *                 return True
 */
    case 0:

    /* "plastid/genomics/roitools.pyx":754
 *             return self._cmp_helper(other,EQ) == False
 *         elif cmptype == LT:
 *             if schrom < ochrom:             # <<<<<<<<<<<<<<
 *                 return True
 *             elif schrom > ochrom:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_schrom, __pyx_v_ochrom, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "plastid/genomics/roitools.pyx":755
 *         elif cmptype == LT:
 *             if schrom < ochrom:
 *                 return True             # <<<<<<<<<<<<<<
 *             elif schrom > ochrom:
 *                 return False
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":754
 *             return self._cmp_helper(other,EQ) == False
 *         elif cmptype == LT:
 *             if schrom < ochrom:             # <<<<<<<<<<<<<<
 *                 return True
 *             elif schrom > ochrom:
 */
    }

    /* "plastid/genomics/roitools.pyx":756
 *             if schrom < ochrom:
 *                 return True
 *             elif schrom > ochrom:             # <<<<<<<<<<<<<<
 *                 return False
 *             elif schrom == ochrom:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_schrom, __pyx_v_ochrom, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "plastid/genomics/roitools.pyx":757
 *                 return True
 *             elif schrom > ochrom:
 *                 return False             # <<<<<<<<<<<<<<
 *             elif schrom == ochrom:
 *                 sstart = self.start
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":756
 *             if schrom < ochrom:
 *                 return True
 *             elif schrom > ochrom:             # <<<<<<<<<<<<<<
 *                 return False
 *             elif schrom == ochrom:
 */
    }

    /* "plastid/genomics/roitools.pyx":758
 *             elif schrom > ochrom:
 *                 return False
 *             elif schrom == ochrom:             # <<<<<<<<<<<<<<
 *                 sstart = self.start
 *                 ostart = other.start
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_schrom, __pyx_v_ochrom, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {

      /* "plastid/genomics/roitools.pyx":759
 *                 return False
 *             elif schrom == ochrom:
 *                 sstart = self.start             # <<<<<<<<<<<<<<
 *                 ostart = other.start
 *                 if sstart < ostart:
 */
      __pyx_t_10 = __pyx_v_self->start;
      __pyx_v_sstart = __pyx_t_10;

      /* "plastid/genomics/roitools.pyx":760
 *             elif schrom == ochrom:
 *                 sstart = self.start
 *                 ostart = other.start             # <<<<<<<<<<<<<<
 *                 if sstart < ostart:
 *                     return True
 */
      __pyx_t_10 = __pyx_v_other->start;
      __pyx_v_ostart = __pyx_t_10;

      /* "plastid/genomics/roitools.pyx":761
 *                 sstart = self.start
 *                 ostart = other.start
 *                 if sstart < ostart:             # <<<<<<<<<<<<<<
 *                     return True
 *                 elif sstart > ostart:
 */
      __pyx_t_8 = ((__pyx_v_sstart < __pyx_v_ostart) != 0);
      if (__pyx_t_8) {

        /* "plastid/genomics/roitools.pyx":762
 *                 ostart = other.start
 *                 if sstart < ostart:
 *                     return True             # <<<<<<<<<<<<<<
 *                 elif sstart > ostart:
 *                     return False
 */
        __pyx_r = 1;
        goto __pyx_L0;

        /* "plastid/genomics/roitools.pyx":761
 *                 sstart = self.start
 *                 ostart = other.start
 *                 if sstart < ostart:             # <<<<<<<<<<<<<<
 *                     return True
 *                 elif sstart > ostart:
 */
      }

      /* "plastid/genomics/roitools.pyx":763
 *                 if sstart < ostart:
 *                     return True
 *                 elif sstart > ostart:             # <<<<<<<<<<<<<<
 *                     return False
 *                 elif sstart == ostart:
 */
      __pyx_t_8 = ((__pyx_v_sstart > __pyx_v_ostart) != 0);
      if (__pyx_t_8) {

        /* "plastid/genomics/roitools.pyx":764
 *                     return True
 *                 elif sstart > ostart:
 *                     return False             # <<<<<<<<<<<<<<
 *                 elif sstart == ostart:
 *                     send = self.end
 */
        __pyx_r = 0;
        goto __pyx_L0;

        /* "plastid/genomics/roitools.pyx":763
 *                 if sstart < ostart:
 *                     return True
 *                 elif sstart > ostart:             # <<<<<<<<<<<<<<
 *                     return False
 *                 elif sstart == ostart:
 */
      }

      /* "plastid/genomics/roitools.pyx":765
 *                 elif sstart > ostart:
 *                     return False
 *                 elif sstart == ostart:             # <<<<<<<<<<<<<<
 *                     send = self.end
 *                     oend = other.end
 */
      __pyx_t_8 = ((__pyx_v_sstart == __pyx_v_ostart) != 0);
      if (__pyx_t_8) {

        /* "plastid/genomics/roitools.pyx":766
 *                     return False
 *                 elif sstart == ostart:
 *                     send = self.end             # <<<<<<<<<<<<<<
 *                     oend = other.end
 *                     if send < oend:
 */
        __pyx_t_10 = __pyx_v_self->end;
        __pyx_v_send = __pyx_t_10;

        /* "plastid/genomics/roitools.pyx":767
 *                 elif sstart == ostart:
 *                     send = self.end
 *                     oend = other.end             # <<<<<<<<<<<<<<
 *                     if send < oend:
 *                         return True
 */
        __pyx_t_10 = __pyx_v_other->end;
        __pyx_v_oend = __pyx_t_10;

        /* "plastid/genomics/roitools.pyx":768
 *                     send = self.end
 *                     oend = other.end
 *                     if send < oend:             # <<<<<<<<<<<<<<
 *                         return True
 *                     elif send > oend:
 */
        __pyx_t_8 = ((__pyx_v_send < __pyx_v_oend) != 0);
        if (__pyx_t_8) {

          /* "plastid/genomics/roitools.pyx":769
 *                     oend = other.end
 *                     if send < oend:
 *                         return True             # <<<<<<<<<<<<<<
 *                     elif send > oend:
 *                         return False
 */
          __pyx_r = 1;
          goto __pyx_L0;

          /* "plastid/genomics/roitools.pyx":768
 *                     send = self.end
 *                     oend = other.end
 *                     if send < oend:             # <<<<<<<<<<<<<<
 *                         return True
 *                     elif send > oend:
 */
        }

        /* "plastid/genomics/roitools.pyx":770
 *                     if send < oend:
 *                         return True
 *                     elif send > oend:             # <<<<<<<<<<<<<<
 *                         return False
 *                     elif send == oend:
 */
        __pyx_t_8 = ((__pyx_v_send > __pyx_v_oend) != 0);
        if (__pyx_t_8) {

          /* "plastid/genomics/roitools.pyx":771
 *                         return True
 *                     elif send > oend:
 *                         return False             # <<<<<<<<<<<<<<
 *                     elif send == oend:
 *                         return self.c_strand < other.c_strand
 */
          __pyx_r = 0;
          goto __pyx_L0;

          /* "plastid/genomics/roitools.pyx":770
 *                     if send < oend:
 *                         return True
 *                     elif send > oend:             # <<<<<<<<<<<<<<
 *                         return False
 *                     elif send == oend:
 */
        }

        /* "plastid/genomics/roitools.pyx":772
 *                     elif send > oend:
 *                         return False
 *                     elif send == oend:             # <<<<<<<<<<<<<<
 *                         return self.c_strand < other.c_strand
 *         elif cmptype == GT:
 */
        __pyx_t_8 = ((__pyx_v_send == __pyx_v_oend) != 0);
        if (__pyx_t_8) {

          /* "plastid/genomics/roitools.pyx":773
 *                         return False
 *                     elif send == oend:
 *                         return self.c_strand < other.c_strand             # <<<<<<<<<<<<<<
 *         elif cmptype == GT:
 *             return other._cmp_helper(self,LT) # (other < self)
 */
          __pyx_r = (__pyx_v_self->c_strand < __pyx_v_other->c_strand);
          goto __pyx_L0;

          /* "plastid/genomics/roitools.pyx":772
 *                     elif send > oend:
 *                         return False
 *                     elif send == oend:             # <<<<<<<<<<<<<<
 *                         return self.c_strand < other.c_strand
 *         elif cmptype == GT:
 */
        }

        /* "plastid/genomics/roitools.pyx":765
 *                 elif sstart > ostart:
 *                     return False
 *                 elif sstart == ostart:             # <<<<<<<<<<<<<<
 *                     send = self.end
 *                     oend = other.end
 */
      }

      /* "plastid/genomics/roitools.pyx":758
 *             elif schrom > ochrom:
 *                 return False
 *             elif schrom == ochrom:             # <<<<<<<<<<<<<<
 *                 sstart = self.start
 *                 ostart = other.start
 */
    }

    /* "plastid/genomics/roitools.pyx":753
 *         elif cmptype == NEQ:
 *             return self._cmp_helper(other,EQ) == False
 *         elif cmptype == LT:             # <<<<<<<<<<<<<<
 *             if schrom < ochrom:
 *                 return True
 */
    break;

    /* "plastid/genomics/roitools.pyx":774
 *                     elif send == oend:
 *                         return self.c_strand < other.c_strand
 *         elif cmptype == GT:             # <<<<<<<<<<<<<<
 *             return other._cmp_helper(self,LT) # (other < self)
 *         elif cmptype == LEQ:
 */
    case 4:

    /* "plastid/genomics/roitools.pyx":775
 *                         return self.c_strand < other.c_strand
 *         elif cmptype == GT:
 *             return other._cmp_helper(self,LT) # (other < self)             # <<<<<<<<<<<<<<
 *         elif cmptype == LEQ:
 *             return self._cmp_helper(other,LT) or self._cmp_helper(other,EQ)
 */
    __pyx_r = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_other->__pyx_vtab)->_cmp_helper(__pyx_v_other, __pyx_v_self, 0, 0);
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":774
 *                     elif send == oend:
 *                         return self.c_strand < other.c_strand
 *         elif cmptype == GT:             # <<<<<<<<<<<<<<
 *             return other._cmp_helper(self,LT) # (other < self)
 *         elif cmptype == LEQ:
 */
    break;

    /* "plastid/genomics/roitools.pyx":776
 *         elif cmptype == GT:
 *             return other._cmp_helper(self,LT) # (other < self)
 *         elif cmptype == LEQ:             # <<<<<<<<<<<<<<
 *             return self._cmp_helper(other,LT) or self._cmp_helper(other,EQ)
 *         elif cmptype == GEQ:
 */
    case 1:

    /* "plastid/genomics/roitools.pyx":777
 *             return other._cmp_helper(self,LT) # (other < self)
 *         elif cmptype == LEQ:
 *             return self._cmp_helper(other,LT) or self._cmp_helper(other,EQ)             # <<<<<<<<<<<<<<
 *         elif cmptype == GEQ:
 *             return other._cmp_helper(self,LT) or self._cmp_helper(other,EQ)
 */
    __pyx_t_9 = (((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self->__pyx_vtab)->_cmp_helper(__pyx_v_self, __pyx_v_other, 0, 0) != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L10_bool_binop_done;
    }
    __pyx_t_9 = (((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self->__pyx_vtab)->_cmp_helper(__pyx_v_self, __pyx_v_other, 2, 0) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L10_bool_binop_done:;
    __pyx_r = __pyx_t_8;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":776
 *         elif cmptype == GT:
 *             return other._cmp_helper(self,LT) # (other < self)
 *         elif cmptype == LEQ:             # <<<<<<<<<<<<<<
 *             return self._cmp_helper(other,LT) or self._cmp_helper(other,EQ)
 *         elif cmptype == GEQ:
 */
    break;

    /* "plastid/genomics/roitools.pyx":778
 *         elif cmptype == LEQ:
 *             return self._cmp_helper(other,LT) or self._cmp_helper(other,EQ)
 *         elif cmptype == GEQ:             # <<<<<<<<<<<<<<
 *             return other._cmp_helper(self,LT) or self._cmp_helper(other,EQ)
 *         else:
 */
    case 5:

    /* "plastid/genomics/roitools.pyx":779
 *             return self._cmp_helper(other,LT) or self._cmp_helper(other,EQ)
 *         elif cmptype == GEQ:
 *             return other._cmp_helper(self,LT) or self._cmp_helper(other,EQ)             # <<<<<<<<<<<<<<
 *         else:
 *             raise AttributeError("Comparison operation not defined")
 */
    __pyx_t_9 = (((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_other->__pyx_vtab)->_cmp_helper(__pyx_v_other, __pyx_v_self, 0, 0) != 0);
    if (!__pyx_t_9) {
    } else {
      __pyx_t_8 = __pyx_t_9;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_9 = (((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self->__pyx_vtab)->_cmp_helper(__pyx_v_self, __pyx_v_other, 2, 0) != 0);
    __pyx_t_8 = __pyx_t_9;
    __pyx_L12_bool_binop_done:;
    __pyx_r = __pyx_t_8;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":778
 *         elif cmptype == LEQ:
 *             return self._cmp_helper(other,LT) or self._cmp_helper(other,EQ)
 *         elif cmptype == GEQ:             # <<<<<<<<<<<<<<
 *             return other._cmp_helper(self,LT) or self._cmp_helper(other,EQ)
 *         else:
 */
    break;
    default:

    /* "plastid/genomics/roitools.pyx":781
 *             return other._cmp_helper(self,LT) or self._cmp_helper(other,EQ)
 *         else:
 *             raise AttributeError("Comparison operation not defined")             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self,other):
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __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 = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  /* "plastid/genomics/roitools.pyx":742
 * 
 *     # TODO: suspend type check via decorator, since we have already done this
 *     cpdef bint _cmp_helper(self,GenomicSegment other,int cmptype):             # <<<<<<<<<<<<<<
 *         nonecheck(other,"GenomicSegment eq/neq","other")
 *         schrom = self.chrom
 */

  /* function exit code */
  __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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("plastid.genomics.roitools.GenomicSegment._cmp_helper", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_schrom);
  __Pyx_XDECREF(__pyx_v_ochrom);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_19_cmp_helper(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_18_cmp_helper[] = "GenomicSegment._cmp_helper(self, GenomicSegment other, int cmptype) -> bool";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_19_cmp_helper(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other = 0;
  int __pyx_v_cmptype;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_cmp_helper (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_other,&__pyx_n_s_cmptype,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_other)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cmptype)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_cmp_helper", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_cmp_helper") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __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_other = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)values[0]);
    __pyx_v_cmptype = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_cmptype == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_cmp_helper", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment._cmp_helper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_18_cmp_helper(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self), __pyx_v_other, __pyx_v_cmptype);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_18_cmp_helper(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_v_cmptype) {
  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("_cmp_helper", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment__cmp_helper(__pyx_v_self, __pyx_v_other, __pyx_v_cmptype, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment._cmp_helper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":783
 *             raise AttributeError("Comparison operation not defined")
 * 
 *     def __contains__(self,other):             # <<<<<<<<<<<<<<
 *         """Test whether this segment contains `other`, where containment is
 *         defined as all positions in `other` being present in self, when both
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_21__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__[] = "Test whether this segment contains `other`, where containment is\n        defined as all positions in `other` being present in self, when both\n        `self` and `other` share the same chromosome and strand.\n           \n        Parameters\n        ----------\n        other : |GenomicSegment|\n            Query segment\n        \n        Returns\n        -------\n        bool\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__;
#endif
static int __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_21__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "plastid/genomics/roitools.pyx":797
 *         bool
 *         """
 *         nonecheck(other,"GenomicSegment.__eq__","other")             # <<<<<<<<<<<<<<
 *         return self.contains(other)
 * 
 */
  __pyx_f_7plastid_8genomics_8roitools_nonecheck(__pyx_v_other, __pyx_kp_s_GenomicSegment___eq, __pyx_n_s_other);

  /* "plastid/genomics/roitools.pyx":798
 *         """
 *         nonecheck(other,"GenomicSegment.__eq__","other")
 *         return self.contains(other)             # <<<<<<<<<<<<<<
 * 
 *     cpdef bint contains(self,GenomicSegment other):
 */
  if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self->__pyx_vtab)->contains(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_other), 0);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":783
 *             raise AttributeError("Comparison operation not defined")
 * 
 *     def __contains__(self,other):             # <<<<<<<<<<<<<<
 *         """Test whether this segment contains `other`, where containment is
 *         defined as all positions in `other` being present in self, when both
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":800
 *         return self.contains(other)
 * 
 *     cpdef bint contains(self,GenomicSegment other):             # <<<<<<<<<<<<<<
 *         """Test whether this segment contains `other`, where containment is
 *         defined as all positions in `other` being present in self, when both
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_23contains(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static int __pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_contains(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_skip_dispatch) {
  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;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("contains", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contains); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __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_7plastid_8genomics_8roitools_14GenomicSegment_23contains)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "plastid/genomics/roitools.pyx":814
 *         bool
 *         """
 *         nonecheck(other,"GenomicSegment.contains","other")             # <<<<<<<<<<<<<<
 *         return self.chrom == other.chrom and\
 *                self.c_strand == other.c_strand and\
 */
  __pyx_f_7plastid_8genomics_8roitools_nonecheck(((PyObject *)__pyx_v_other), __pyx_kp_s_GenomicSegment_contains, __pyx_n_s_other);

  /* "plastid/genomics/roitools.pyx":815
 *         """
 *         nonecheck(other,"GenomicSegment.contains","other")
 *         return self.chrom == other.chrom and\             # <<<<<<<<<<<<<<
 *                self.c_strand == other.c_strand and\
 *                (other.start >= self.start and other.end <= self.end and other.end >= other.start)
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_self->chrom, __pyx_v_other->chrom, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {
  } else {
    __pyx_t_6 = __pyx_t_8;
    goto __pyx_L3_bool_binop_done;
  }

  /* "plastid/genomics/roitools.pyx":816
 *         nonecheck(other,"GenomicSegment.contains","other")
 *         return self.chrom == other.chrom and\
 *                self.c_strand == other.c_strand and\             # <<<<<<<<<<<<<<
 *                (other.start >= self.start and other.end <= self.end and other.end >= other.start)
 * 
 */
  __pyx_t_8 = ((__pyx_v_self->c_strand == __pyx_v_other->c_strand) != 0);
  if (__pyx_t_8) {
  } else {
    __pyx_t_6 = __pyx_t_8;
    goto __pyx_L3_bool_binop_done;
  }

  /* "plastid/genomics/roitools.pyx":817
 *         return self.chrom == other.chrom and\
 *                self.c_strand == other.c_strand and\
 *                (other.start >= self.start and other.end <= self.end and other.end >= other.start)             # <<<<<<<<<<<<<<
 * 
 *     cpdef bint overlaps(self,GenomicSegment other):
 */
  __pyx_t_8 = ((__pyx_v_other->start >= __pyx_v_self->start) != 0);
  if (__pyx_t_8) {
  } else {
    __pyx_t_6 = __pyx_t_8;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_8 = ((__pyx_v_other->end <= __pyx_v_self->end) != 0);
  if (__pyx_t_8) {
  } else {
    __pyx_t_6 = __pyx_t_8;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_8 = ((__pyx_v_other->end >= __pyx_v_other->start) != 0);
  __pyx_t_6 = __pyx_t_8;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_6;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":800
 *         return self.contains(other)
 * 
 *     cpdef bint contains(self,GenomicSegment other):             # <<<<<<<<<<<<<<
 *         """Test whether this segment contains `other`, where containment is
 *         defined as all positions in `other` being present in self, when both
 */

  /* function exit code */
  __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_WriteUnraisable("plastid.genomics.roitools.GenomicSegment.contains", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_23contains(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_22contains[] = "GenomicSegment.contains(self, GenomicSegment other) -> bool\nTest whether this segment contains `other`, where containment is\n        defined as all positions in `other` being present in self, when both\n        `self` and `other` share the same chromosome and strand.\n           \n        Parameters\n        ----------\n        other : |GenomicSegment|\n            Query segment\n        \n        Returns\n        -------\n        bool\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_23contains(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("contains (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_22contains(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self), ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_22contains(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other) {
  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("contains", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_contains(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.contains", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":819
 *                (other.start >= self.start and other.end <= self.end and other.end >= other.start)
 * 
 *     cpdef bint overlaps(self,GenomicSegment other):             # <<<<<<<<<<<<<<
 *         """Test whether this segment overlaps `other`, where overlap is defined
 *         as sharing: a chromosome, a strand, and a subset of coordinates.
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_25overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static int __pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other, int __pyx_skip_dispatch) {
  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;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("overlaps", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_overlaps); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __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_7plastid_8genomics_8roitools_14GenomicSegment_25overlaps)) {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_other));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_other));
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_other));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "plastid/genomics/roitools.pyx":832
 *         bool
 *         """
 *         nonecheck(other,"GenomicSegment.overlaps","other")             # <<<<<<<<<<<<<<
 *         if self.chrom == other.chrom and self.c_strand == other.c_strand:
 *             if (self.start >= other.start and self.start < other.end) or\
 */
  __pyx_f_7plastid_8genomics_8roitools_nonecheck(((PyObject *)__pyx_v_other), __pyx_kp_s_GenomicSegment_overlaps, __pyx_n_s_other);

  /* "plastid/genomics/roitools.pyx":833
 *         """
 *         nonecheck(other,"GenomicSegment.overlaps","other")
 *         if self.chrom == other.chrom and self.c_strand == other.c_strand:             # <<<<<<<<<<<<<<
 *             if (self.start >= other.start and self.start < other.end) or\
 *                (other.start >= self.start and other.start < self.end):
 */
  __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_self->chrom, __pyx_v_other->chrom, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {
  } else {
    __pyx_t_6 = __pyx_t_8;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_8 = ((__pyx_v_self->c_strand == __pyx_v_other->c_strand) != 0);
  __pyx_t_6 = __pyx_t_8;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_6) {

    /* "plastid/genomics/roitools.pyx":834
 *         nonecheck(other,"GenomicSegment.overlaps","other")
 *         if self.chrom == other.chrom and self.c_strand == other.c_strand:
 *             if (self.start >= other.start and self.start < other.end) or\             # <<<<<<<<<<<<<<
 *                (other.start >= self.start and other.start < self.end):
 *                    return True
 */
    __pyx_t_8 = ((__pyx_v_self->start >= __pyx_v_other->start) != 0);
    if (!__pyx_t_8) {
      goto __pyx_L8_next_or;
    } else {
    }
    __pyx_t_8 = ((__pyx_v_self->start < __pyx_v_other->end) != 0);
    if (!__pyx_t_8) {
    } else {
      __pyx_t_6 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_L8_next_or:;

    /* "plastid/genomics/roitools.pyx":835
 *         if self.chrom == other.chrom and self.c_strand == other.c_strand:
 *             if (self.start >= other.start and self.start < other.end) or\
 *                (other.start >= self.start and other.start < self.end):             # <<<<<<<<<<<<<<
 *                    return True
 * 
 */
    __pyx_t_8 = ((__pyx_v_other->start >= __pyx_v_self->start) != 0);
    if (__pyx_t_8) {
    } else {
      __pyx_t_6 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_8 = ((__pyx_v_other->start < __pyx_v_self->end) != 0);
    __pyx_t_6 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;

    /* "plastid/genomics/roitools.pyx":834
 *         nonecheck(other,"GenomicSegment.overlaps","other")
 *         if self.chrom == other.chrom and self.c_strand == other.c_strand:
 *             if (self.start >= other.start and self.start < other.end) or\             # <<<<<<<<<<<<<<
 *                (other.start >= self.start and other.start < self.end):
 *                    return True
 */
    if (__pyx_t_6) {

      /* "plastid/genomics/roitools.pyx":836
 *             if (self.start >= other.start and self.start < other.end) or\
 *                (other.start >= self.start and other.start < self.end):
 *                    return True             # <<<<<<<<<<<<<<
 * 
 *         return False
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":834
 *         nonecheck(other,"GenomicSegment.overlaps","other")
 *         if self.chrom == other.chrom and self.c_strand == other.c_strand:
 *             if (self.start >= other.start and self.start < other.end) or\             # <<<<<<<<<<<<<<
 *                (other.start >= self.start and other.start < self.end):
 *                    return True
 */
    }

    /* "plastid/genomics/roitools.pyx":833
 *         """
 *         nonecheck(other,"GenomicSegment.overlaps","other")
 *         if self.chrom == other.chrom and self.c_strand == other.c_strand:             # <<<<<<<<<<<<<<
 *             if (self.start >= other.start and self.start < other.end) or\
 *                (other.start >= self.start and other.start < self.end):
 */
  }

  /* "plastid/genomics/roitools.pyx":838
 *                    return True
 * 
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     cpdef str as_igv_str(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":819
 *                (other.start >= self.start and other.end <= self.end and other.end >= other.start)
 * 
 *     cpdef bint overlaps(self,GenomicSegment other):             # <<<<<<<<<<<<<<
 *         """Test whether this segment overlaps `other`, where overlap is defined
 *         as sharing: a chromosome, a strand, and a subset of coordinates.
 */

  /* function exit code */
  __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_WriteUnraisable("plastid.genomics.roitools.GenomicSegment.overlaps", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_25overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_24overlaps[] = "GenomicSegment.overlaps(self, GenomicSegment other) -> bool\nTest whether this segment overlaps `other`, where overlap is defined\n        as sharing: a chromosome, a strand, and a subset of coordinates.\n           \n        Parameters\n        ----------\n        other : |GenomicSegment|\n            Query segment\n        \n        Returns\n        -------\n        bool\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_25overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("overlaps (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_24overlaps(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self), ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_other));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_24overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_other) {
  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("overlaps", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_overlaps(__pyx_v_self, __pyx_v_other, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.overlaps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":840
 *         return False
 * 
 *     cpdef str as_igv_str(self):             # <<<<<<<<<<<<<<
 *         """Format as an IGV location string"""
 *         return "%s:%s-%s" % (self.chrom, self.start+1, self.end+1)
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_27as_igv_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_as_igv_str(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self, int __pyx_skip_dispatch) {
  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("as_igv_str", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_as_igv_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __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_7plastid_8genomics_8roitools_14GenomicSegment_27as_igv_str)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyObject*)__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;
  }

  /* "plastid/genomics/roitools.pyx":842
 *     cpdef str as_igv_str(self):
 *         """Format as an IGV location string"""
 *         return "%s:%s-%s" % (self.chrom, self.start+1, self.end+1)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_self->start + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_self->end + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __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 = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->chrom);
  __Pyx_GIVEREF(__pyx_v_self->chrom);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->chrom);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_2))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":840
 *         return False
 * 
 *     cpdef str as_igv_str(self):             # <<<<<<<<<<<<<<
 *         """Format as an IGV location string"""
 *         return "%s:%s-%s" % (self.chrom, self.start+1, self.end+1)
 */

  /* function exit code */
  __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("plastid.genomics.roitools.GenomicSegment.as_igv_str", __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_7plastid_8genomics_8roitools_14GenomicSegment_27as_igv_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_26as_igv_str[] = "GenomicSegment.as_igv_str(self) -> str\nFormat as an IGV location string";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_27as_igv_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_igv_str (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_26as_igv_str(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_26as_igv_str(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__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("as_igv_str", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_as_igv_str(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.as_igv_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":845
 * 
 *     @staticmethod
 *     def from_igv_str(str loc_str, str strand="."):             # <<<<<<<<<<<<<<
 *         """Construct |GenomicSegment| from IGV location string
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_29from_igv_str(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_28from_igv_str[] = "GenomicSegment.from_igv_str(str loc_str, str strand='.')\nConstruct |GenomicSegment| from IGV location string\n        \n        Parameters\n        ----------\n        igvloc : str\n            IGV location string, in format `'chromosome:start-end'`,\n            where `start` and `end` are 1-indexed and half-open\n            \n        strand : str\n            The chromosome strand (`'+'`, `'-'`, or `'.'`)\n            \n        Returns\n        -------\n        |GenomicSegment|\n        ";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_14GenomicSegment_29from_igv_str = {"from_igv_str", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_29from_igv_str, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_28from_igv_str};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_29from_igv_str(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_loc_str = 0;
  PyObject *__pyx_v_strand = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_igv_str (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loc_str,&__pyx_n_s_strand,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject*)__pyx_kp_s__4);
    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_loc_str)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_strand);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_igv_str") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __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_loc_str = ((PyObject*)values[0]);
    __pyx_v_strand = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_igv_str", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.from_igv_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_loc_str), (&PyString_Type), 1, "loc_str", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_strand), (&PyString_Type), 1, "strand", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_28from_igv_str(__pyx_v_loc_str, __pyx_v_strand);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_28from_igv_str(PyObject *__pyx_v_loc_str, PyObject *__pyx_v_strand) {
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_s_start = 0;
  PyObject *__pyx_v_s_end = 0;
  long __pyx_v_start;
  long __pyx_v_end;
  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)(PyObject *);
  long __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_igv_str", 0);

  /* "plastid/genomics/roitools.pyx":865
 *             long start, end
 * 
 *         chrom,s_start,s_end = igvpat.search(loc_str).groups()             # <<<<<<<<<<<<<<
 *         start = long(s_start) - 1
 *         end   = long(s_end) - 1
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_igvpat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_search); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_loc_str); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_loc_str);
    __Pyx_GIVEREF(__pyx_v_loc_str);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_loc_str);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_groups); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  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 = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_4 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 2; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_chrom = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_v_s_start = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_s_end = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "plastid/genomics/roitools.pyx":866
 * 
 *         chrom,s_start,s_end = igvpat.search(loc_str).groups()
 *         start = long(s_start) - 1             # <<<<<<<<<<<<<<
 *         end   = long(s_end) - 1
 *         return GenomicSegment(chrom,start,end,strand)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_s_start);
  __Pyx_GIVEREF(__pyx_v_s_start);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s_start);
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyLong_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_start = __pyx_t_7;

  /* "plastid/genomics/roitools.pyx":867
 *         chrom,s_start,s_end = igvpat.search(loc_str).groups()
 *         start = long(s_start) - 1
 *         end   = long(s_end) - 1             # <<<<<<<<<<<<<<
 *         return GenomicSegment(chrom,start,end,strand)
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_s_end);
  __Pyx_GIVEREF(__pyx_v_s_end);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s_end);
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyLong_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_7 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_end = __pyx_t_7;

  /* "plastid/genomics/roitools.pyx":868
 *         start = long(s_start) - 1
 *         end   = long(s_end) - 1
 *         return GenomicSegment(chrom,start,end,strand)             # <<<<<<<<<<<<<<
 * 
 *     property start:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_end); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_v_chrom);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_strand);
  __Pyx_GIVEREF(__pyx_v_strand);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_strand);
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":845
 * 
 *     @staticmethod
 *     def from_igv_str(str loc_str, str strand="."):             # <<<<<<<<<<<<<<
 *         """Construct |GenomicSegment| from IGV location string
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.GenomicSegment.from_igv_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_s_start);
  __Pyx_XDECREF(__pyx_v_s_end);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":872
 *     property start:
 *         """Zero-indexed (Pythonic) start coordinate of |GenomicSegment|"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.start
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5start_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5start_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_5start___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_5start___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__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);

  /* "plastid/genomics/roitools.pyx":873
 *         """Zero-indexed (Pythonic) start coordinate of |GenomicSegment|"""
 *         def __get__(self):
 *             return self.start             # <<<<<<<<<<<<<<
 * 
 *     property end:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":872
 *     property start:
 *         """Zero-indexed (Pythonic) start coordinate of |GenomicSegment|"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.start
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.start.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":877
 *     property end:
 *         """Zero-indexed, half-open (Pythonic) end coordinate of |GenomicSegment|"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.end
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_3end_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_3end_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_3end___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_3end___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__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);

  /* "plastid/genomics/roitools.pyx":878
 *         """Zero-indexed, half-open (Pythonic) end coordinate of |GenomicSegment|"""
 *         def __get__(self):
 *             return self.end             # <<<<<<<<<<<<<<
 * 
 *     property chrom:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":877
 *     property end:
 *         """Zero-indexed, half-open (Pythonic) end coordinate of |GenomicSegment|"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.end
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.end.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":882
 *     property chrom:
 *         """Chromosome where |GenomicSegment| resides"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.chrom
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5chrom_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5chrom_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_5chrom___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_5chrom___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "plastid/genomics/roitools.pyx":883
 *         """Chromosome where |GenomicSegment| resides"""
 *         def __get__(self):
 *             return self.chrom             # <<<<<<<<<<<<<<
 * 
 *     property strand:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->chrom);
  __pyx_r = __pyx_v_self->chrom;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":882
 *     property chrom:
 *         """Chromosome where |GenomicSegment| resides"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.chrom
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":892
 *           - '.' for unstranded / both strands
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return strand_to_str(self.c_strand)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_6strand_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_6strand_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_6strand___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_6strand___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__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);

  /* "plastid/genomics/roitools.pyx":893
 *         """
 *         def __get__(self):
 *             return strand_to_str(self.c_strand)             # <<<<<<<<<<<<<<
 * 
 *     property c_strand:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7plastid_8genomics_8roitools_strand_to_str(__pyx_v_self->c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":892
 *           - '.' for unstranded / both strands
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return strand_to_str(self.c_strand)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.strand.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":896
 * 
 *     property c_strand:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.c_strand
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_8c_strand_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_8c_strand_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_8c_strand___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_14GenomicSegment_8c_strand___get__(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__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);

  /* "plastid/genomics/roitools.pyx":897
 *     property c_strand:
 *         def __get__(self):
 *             return self.c_strand             # <<<<<<<<<<<<<<
 * 
 * cdef class SegmentChain(object):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_v_self->c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":896
 * 
 *     property c_strand:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.c_strand
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.GenomicSegment.c_strand.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":950
 *     """
 * 
 *     def __cinit__(self,*segments,**attr):             # <<<<<<<<<<<<<<
 *         """Create an |SegmentChain| from zero or more |GenomicSegment| objects
 * 
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_attr = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
  __pyx_v_attr = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_attr)) return -1;
  __Pyx_GOTREF(__pyx_v_attr);
  __Pyx_INCREF(__pyx_args);
  __pyx_v_segments = __pyx_args;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain___cinit__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_segments, __pyx_v_attr);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_segments);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain___cinit__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments, PyObject *__pyx_v_attr) {
  PyObject *__pyx_v_my_chrom = 0;
  PyObject *__pyx_v_my_strand = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg = 0;
  PyObject *__pyx_v_positions = 0;
  int __pyx_v_num_segs;
  PyObject *__pyx_v_new_segments = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);

  /* "plastid/genomics/roitools.pyx":984
 *             str my_chrom, my_strand
 *             GenomicSegment seg
 *             list positions = []             # <<<<<<<<<<<<<<
 *             int num_segs = len(segments)
 *             list new_segments
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_positions = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":985
 *             GenomicSegment seg
 *             list positions = []
 *             int num_segs = len(segments)             # <<<<<<<<<<<<<<
 *             list new_segments
 *             long total_length
 */
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_segments); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_num_segs = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":989
 *             long total_length
 * 
 *         if "type" not in attr:             # <<<<<<<<<<<<<<
 *             attr["type"] = "exon"
 * 
 */
  __pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_type, __pyx_v_attr, Py_NE)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":990
 * 
 *         if "type" not in attr:
 *             attr["type"] = "exon"             # <<<<<<<<<<<<<<
 * 
 *         self.attr = attr
 */
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_type, __pyx_n_s_exon) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":989
 *             long total_length
 * 
 *         if "type" not in attr:             # <<<<<<<<<<<<<<
 *             attr["type"] = "exon"
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":992
 *             attr["type"] = "exon"
 * 
 *         self.attr = attr             # <<<<<<<<<<<<<<
 *         self._mask_segments = []
 *         self._segments      = []
 */
  __Pyx_INCREF(__pyx_v_attr);
  __Pyx_GIVEREF(__pyx_v_attr);
  __Pyx_GOTREF(__pyx_v_self->attr);
  __Pyx_DECREF(__pyx_v_self->attr);
  __pyx_v_self->attr = __pyx_v_attr;

  /* "plastid/genomics/roitools.pyx":993
 * 
 *         self.attr = attr
 *         self._mask_segments = []             # <<<<<<<<<<<<<<
 *         self._segments      = []
 *         self._inverse_hash  = {}
 */
  __pyx_t_1 = PyList_New(0); 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_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_mask_segments);
  __Pyx_DECREF(__pyx_v_self->_mask_segments);
  __pyx_v_self->_mask_segments = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":994
 *         self.attr = attr
 *         self._mask_segments = []
 *         self._segments      = []             # <<<<<<<<<<<<<<
 *         self._inverse_hash  = {}
 *         self.length         = 0
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_segments);
  __Pyx_DECREF(__pyx_v_self->_segments);
  __pyx_v_self->_segments = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":995
 *         self._mask_segments = []
 *         self._segments      = []
 *         self._inverse_hash  = {}             # <<<<<<<<<<<<<<
 *         self.length         = 0
 *         self.masked_length  = 0
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_inverse_hash);
  __Pyx_DECREF(__pyx_v_self->_inverse_hash);
  __pyx_v_self->_inverse_hash = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":996
 *         self._segments      = []
 *         self._inverse_hash  = {}
 *         self.length         = 0             # <<<<<<<<<<<<<<
 *         self.masked_length  = 0
 *         self.spanning_segment = NullSegment
 */
  __pyx_v_self->length = 0;

  /* "plastid/genomics/roitools.pyx":997
 *         self._inverse_hash  = {}
 *         self.length         = 0
 *         self.masked_length  = 0             # <<<<<<<<<<<<<<
 *         self.spanning_segment = NullSegment
 *         self._position_mask = array.clone(mask_template,0,False)
 */
  __pyx_v_self->masked_length = 0;

  /* "plastid/genomics/roitools.pyx":998
 *         self.length         = 0
 *         self.masked_length  = 0
 *         self.spanning_segment = NullSegment             # <<<<<<<<<<<<<<
 *         self._position_mask = array.clone(mask_template,0,False)
 *         if num_segs == 0:
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_7plastid_8genomics_8roitools_NullSegment));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_7plastid_8genomics_8roitools_NullSegment));
  __Pyx_GOTREF(__pyx_v_self->spanning_segment);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->spanning_segment));
  __pyx_v_self->spanning_segment = __pyx_v_7plastid_8genomics_8roitools_NullSegment;

  /* "plastid/genomics/roitools.pyx":999
 *         self.masked_length  = 0
 *         self.spanning_segment = NullSegment
 *         self._position_mask = array.clone(mask_template,0,False)             # <<<<<<<<<<<<<<
 *         if num_segs == 0:
 *             self._position_hash   = array.clone(hash_template,0,False)
 */
  if (!(likely(((__pyx_v_7plastid_8genomics_8roitools_mask_template) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_7plastid_8genomics_8roitools_mask_template, __pyx_ptype_7cpython_5array_array))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_7plastid_8genomics_8roitools_mask_template;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = ((PyObject *)__pyx_f_7cpython_5array_clone(((arrayobject *)__pyx_t_1), 0, 0)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->_position_mask);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_position_mask));
  __pyx_v_self->_position_mask = ((arrayobject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "plastid/genomics/roitools.pyx":1000
 *         self.spanning_segment = NullSegment
 *         self._position_mask = array.clone(mask_template,0,False)
 *         if num_segs == 0:             # <<<<<<<<<<<<<<
 *             self._position_hash   = array.clone(hash_template,0,False)
 *             #self._position_mask   = array.clone(mask_template,0,False)
 */
  switch (__pyx_v_num_segs) {
    case 0:

    /* "plastid/genomics/roitools.pyx":1001
 *         self._position_mask = array.clone(mask_template,0,False)
 *         if num_segs == 0:
 *             self._position_hash   = array.clone(hash_template,0,False)             # <<<<<<<<<<<<<<
 *             #self._position_mask   = array.clone(mask_template,0,False)
 *         elif num_segs == 1:
 */
    if (!(likely(((__pyx_v_7plastid_8genomics_8roitools_hash_template) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_7plastid_8genomics_8roitools_hash_template, __pyx_ptype_7cpython_5array_array))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __pyx_v_7plastid_8genomics_8roitools_hash_template;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_1 = ((PyObject *)__pyx_f_7cpython_5array_clone(((arrayobject *)__pyx_t_5), 0, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->_position_hash);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->_position_hash));
    __pyx_v_self->_position_hash = ((arrayobject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1000
 *         self.spanning_segment = NullSegment
 *         self._position_mask = array.clone(mask_template,0,False)
 *         if num_segs == 0:             # <<<<<<<<<<<<<<
 *             self._position_hash   = array.clone(hash_template,0,False)
 *             #self._position_mask   = array.clone(mask_template,0,False)
 */
    break;

    /* "plastid/genomics/roitools.pyx":1003
 *             self._position_hash   = array.clone(hash_template,0,False)
 *             #self._position_mask   = array.clone(mask_template,0,False)
 *         elif num_segs == 1:             # <<<<<<<<<<<<<<
 *             self._set_segments(list(segments))
 *         else:
 */
    case 1:

    /* "plastid/genomics/roitools.pyx":1004
 *             #self._position_mask   = array.clone(mask_template,0,False)
 *         elif num_segs == 1:
 *             self._set_segments(list(segments))             # <<<<<<<<<<<<<<
 *         else:
 *             check_segments(self,segments)
 */
    __pyx_t_1 = PySequence_List(__pyx_v_segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->_set_segments(__pyx_v_self, ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_4 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1003
 *             self._position_hash   = array.clone(hash_template,0,False)
 *             #self._position_mask   = array.clone(mask_template,0,False)
 *         elif num_segs == 1:             # <<<<<<<<<<<<<<
 *             self._set_segments(list(segments))
 *         else:
 */
    break;
    default:

    /* "plastid/genomics/roitools.pyx":1006
 *             self._set_segments(list(segments))
 *         else:
 *             check_segments(self,segments)             # <<<<<<<<<<<<<<
 *             seg = segments[0]
 *             my_chrom  = seg.chrom
 */
    __pyx_t_4 = __pyx_f_7plastid_8genomics_8roitools_check_segments(__pyx_v_self, __pyx_v_segments); if (unlikely(__pyx_t_4 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":1007
 *         else:
 *             check_segments(self,segments)
 *             seg = segments[0]             # <<<<<<<<<<<<<<
 *             my_chrom  = seg.chrom
 *             my_strand = seg.strand
 */
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_segments, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_seg = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1008
 *             check_segments(self,segments)
 *             seg = segments[0]
 *             my_chrom  = seg.chrom             # <<<<<<<<<<<<<<
 *             my_strand = seg.strand
 * 
 */
    __pyx_t_1 = __pyx_v_seg->chrom;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v_my_chrom = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1009
 *             seg = segments[0]
 *             my_chrom  = seg.chrom
 *             my_strand = seg.strand             # <<<<<<<<<<<<<<
 * 
 *             # add new positions
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_seg), __pyx_n_s_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_my_strand = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1012
 * 
 *             # add new positions
 *             for seg in segments:             # <<<<<<<<<<<<<<
 *                 positions.extend(range(seg.start,seg.end))
 * 
 */
    __pyx_t_1 = __pyx_v_segments; __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_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF_SET(__pyx_v_seg, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "plastid/genomics/roitools.pyx":1013
 *             # add new positions
 *             for seg in segments:
 *                 positions.extend(range(seg.start,seg.end))             # <<<<<<<<<<<<<<
 * 
 *             # reset variables
 */
      __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_seg->start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_seg->end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __Pyx_PyList_Extend(__pyx_v_positions, __pyx_t_6); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "plastid/genomics/roitools.pyx":1012
 * 
 *             # add new positions
 *             for seg in segments:             # <<<<<<<<<<<<<<
 *                 positions.extend(range(seg.start,seg.end))
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1016
 * 
 *             # reset variables
 *             new_segments = positionlist_to_segments(my_chrom,my_strand,sorted(set(positions)))             # <<<<<<<<<<<<<<
 *             self._set_segments(new_segments)
 * 
 */
    __pyx_t_6 = PySet_New(__pyx_v_positions); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PySequence_List(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_8 = PyList_Sort(__pyx_t_1); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments(__pyx_v_my_chrom, __pyx_v_my_strand, ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_new_segments = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "plastid/genomics/roitools.pyx":1017
 *             # reset variables
 *             new_segments = positionlist_to_segments(my_chrom,my_strand,sorted(set(positions)))
 *             self._set_segments(new_segments)             # <<<<<<<<<<<<<<
 * 
 *     cdef bint _set_segments(self, list segments) except False:
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->_set_segments(__pyx_v_self, __pyx_v_new_segments); if (unlikely(__pyx_t_4 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  /* "plastid/genomics/roitools.pyx":950
 *     """
 * 
 *     def __cinit__(self,*segments,**attr):             # <<<<<<<<<<<<<<
 *         """Create an |SegmentChain| from zero or more |GenomicSegment| objects
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  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_7);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_my_chrom);
  __Pyx_XDECREF(__pyx_v_my_strand);
  __Pyx_XDECREF((PyObject *)__pyx_v_seg);
  __Pyx_XDECREF(__pyx_v_positions);
  __Pyx_XDECREF(__pyx_v_new_segments);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1019
 *             self._set_segments(new_segments)
 * 
 *     cdef bint _set_segments(self, list segments) except False:             # <<<<<<<<<<<<<<
 *         """Set `self._segments` and update position hashes, assuming `segments`
 *         have passed the following criteria:
 */

static int __pyx_f_7plastid_8genomics_8roitools_12SegmentChain__set_segments(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments) {
  int __pyx_v_num_segs;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_segment = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg0 = 0;
  long __pyx_v_length;
  long __pyx_v_x;
  long __pyx_v_c;
  arrayobject *__pyx_v_my_hash = 0;
  __Pyx_memviewslice __pyx_v_my_view = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_segs = NULL;
  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;
  Py_ssize_t __pyx_t_5;
  long __pyx_t_6;
  __Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_set_segments", 0);

  /* "plastid/genomics/roitools.pyx":1062
 *         """
 *         cdef:
 *             int num_segs = len(segments)             # <<<<<<<<<<<<<<
 *             GenomicSegment segment, seg0
 *             long length = sum([len(X) for X in segments])
 */
  if (unlikely(__pyx_v_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_GET_SIZE(__pyx_v_segments); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_num_segs = __pyx_t_1;

  /* "plastid/genomics/roitools.pyx":1064
 *             int num_segs = len(segments)
 *             GenomicSegment segment, seg0
 *             long length = sum([len(X) for X in segments])             # <<<<<<<<<<<<<<
 *             long x, c
 *             array.array my_hash = array.clone(hash_template,length,False)
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __pyx_v_segments; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_5 = PyObject_Length(__pyx_v_X); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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 = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_long(__pyx_t_2); if (unlikely((__pyx_t_6 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_length = __pyx_t_6;

  /* "plastid/genomics/roitools.pyx":1066
 *             long length = sum([len(X) for X in segments])
 *             long x, c
 *             array.array my_hash = array.clone(hash_template,length,False)             # <<<<<<<<<<<<<<
 *             long [:] my_view = my_hash
 * 
 */
  if (!(likely(((__pyx_v_7plastid_8genomics_8roitools_hash_template) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_7plastid_8genomics_8roitools_hash_template, __pyx_ptype_7cpython_5array_array))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __pyx_v_7plastid_8genomics_8roitools_hash_template;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = ((PyObject *)__pyx_f_7cpython_5array_clone(((arrayobject *)__pyx_t_2), __pyx_v_length, 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_2); __pyx_t_2 = 0;
  __pyx_v_my_hash = ((arrayobject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "plastid/genomics/roitools.pyx":1067
 *             long x, c
 *             array.array my_hash = array.clone(hash_template,length,False)
 *             long [:] my_view = my_hash             # <<<<<<<<<<<<<<
 * 
 *         self._segments = segments
 */
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_long(((PyObject *)__pyx_v_my_hash));
  if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_my_view = __pyx_t_7;
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;

  /* "plastid/genomics/roitools.pyx":1069
 *             long [:] my_view = my_hash
 * 
 *         self._segments = segments             # <<<<<<<<<<<<<<
 *         self.length = length
 *         #self._position_mask = array.clone(mask_template,length,True)
 */
  __Pyx_INCREF(__pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __Pyx_GOTREF(__pyx_v_self->_segments);
  __Pyx_DECREF(__pyx_v_self->_segments);
  __pyx_v_self->_segments = __pyx_v_segments;

  /* "plastid/genomics/roitools.pyx":1070
 * 
 *         self._segments = segments
 *         self.length = length             # <<<<<<<<<<<<<<
 *         #self._position_mask = array.clone(mask_template,length,True)
 *         self._position_hash = my_hash
 */
  __pyx_v_self->length = __pyx_v_length;

  /* "plastid/genomics/roitools.pyx":1072
 *         self.length = length
 *         #self._position_mask = array.clone(mask_template,length,True)
 *         self._position_hash = my_hash             # <<<<<<<<<<<<<<
 *         self.c_reset_masks()
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_my_hash));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_my_hash));
  __Pyx_GOTREF(__pyx_v_self->_position_hash);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_position_hash));
  __pyx_v_self->_position_hash = __pyx_v_my_hash;

  /* "plastid/genomics/roitools.pyx":1073
 *         #self._position_mask = array.clone(mask_template,length,True)
 *         self._position_hash = my_hash
 *         self.c_reset_masks()             # <<<<<<<<<<<<<<
 * 
 *         c = 0
 */
  ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_reset_masks(__pyx_v_self);

  /* "plastid/genomics/roitools.pyx":1075
 *         self.c_reset_masks()
 * 
 *         c = 0             # <<<<<<<<<<<<<<
 *         for segment in segments:
 *             x = segment.start
 */
  __pyx_v_c = 0;

  /* "plastid/genomics/roitools.pyx":1076
 * 
 *         c = 0
 *         for segment in segments:             # <<<<<<<<<<<<<<
 *             x = segment.start
 *             while x < segment.end:
 */
  if (unlikely(__pyx_v_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __pyx_v_segments; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; 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);
    #endif
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_segment, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":1077
 *         c = 0
 *         for segment in segments:
 *             x = segment.start             # <<<<<<<<<<<<<<
 *             while x < segment.end:
 *                 my_view[c] = x
 */
    __pyx_t_6 = __pyx_v_segment->start;
    __pyx_v_x = __pyx_t_6;

    /* "plastid/genomics/roitools.pyx":1078
 *         for segment in segments:
 *             x = segment.start
 *             while x < segment.end:             # <<<<<<<<<<<<<<
 *                 my_view[c] = x
 *                 c += 1
 */
    while (1) {
      __pyx_t_8 = ((__pyx_v_x < __pyx_v_segment->end) != 0);
      if (!__pyx_t_8) break;

      /* "plastid/genomics/roitools.pyx":1079
 *             x = segment.start
 *             while x < segment.end:
 *                 my_view[c] = x             # <<<<<<<<<<<<<<
 *                 c += 1
 *                 x += 1
 */
      __pyx_t_9 = __pyx_v_c;
      __pyx_t_10 = -1;
      if (__pyx_t_9 < 0) {
        __pyx_t_9 += __pyx_v_my_view.shape[0];
        if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 0;
      } else if (unlikely(__pyx_t_9 >= __pyx_v_my_view.shape[0])) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      *((long *) ( /* dim=0 */ (__pyx_v_my_view.data + __pyx_t_9 * __pyx_v_my_view.strides[0]) )) = __pyx_v_x;

      /* "plastid/genomics/roitools.pyx":1080
 *             while x < segment.end:
 *                 my_view[c] = x
 *                 c += 1             # <<<<<<<<<<<<<<
 *                 x += 1
 * 
 */
      __pyx_v_c = (__pyx_v_c + 1);

      /* "plastid/genomics/roitools.pyx":1081
 *                 my_view[c] = x
 *                 c += 1
 *                 x += 1             # <<<<<<<<<<<<<<
 * 
 *         if num_segs == 0:
 */
      __pyx_v_x = (__pyx_v_x + 1);
    }

    /* "plastid/genomics/roitools.pyx":1076
 * 
 *         c = 0
 *         for segment in segments:             # <<<<<<<<<<<<<<
 *             x = segment.start
 *             while x < segment.end:
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "plastid/genomics/roitools.pyx":1083
 *                 x += 1
 * 
 *         if num_segs == 0:             # <<<<<<<<<<<<<<
 *             self.spanning_segment = NullSegment
 *         elif num_segs == 1:
 */
  switch (__pyx_v_num_segs) {
    case 0:

    /* "plastid/genomics/roitools.pyx":1084
 * 
 *         if num_segs == 0:
 *             self.spanning_segment = NullSegment             # <<<<<<<<<<<<<<
 *         elif num_segs == 1:
 *             self.spanning_segment = self._segments[0]
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_7plastid_8genomics_8roitools_NullSegment));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_7plastid_8genomics_8roitools_NullSegment));
    __Pyx_GOTREF(__pyx_v_self->spanning_segment);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->spanning_segment));
    __pyx_v_self->spanning_segment = __pyx_v_7plastid_8genomics_8roitools_NullSegment;

    /* "plastid/genomics/roitools.pyx":1083
 *                 x += 1
 * 
 *         if num_segs == 0:             # <<<<<<<<<<<<<<
 *             self.spanning_segment = NullSegment
 *         elif num_segs == 1:
 */
    break;

    /* "plastid/genomics/roitools.pyx":1085
 *         if num_segs == 0:
 *             self.spanning_segment = NullSegment
 *         elif num_segs == 1:             # <<<<<<<<<<<<<<
 *             self.spanning_segment = self._segments[0]
 *         else:
 */
    case 1:

    /* "plastid/genomics/roitools.pyx":1086
 *             self.spanning_segment = NullSegment
 *         elif num_segs == 1:
 *             self.spanning_segment = self._segments[0]             # <<<<<<<<<<<<<<
 *         else:
 *             segs = self._segments
 */
    if (unlikely(__pyx_v_self->_segments == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_self->_segments, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->spanning_segment);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->spanning_segment));
    __pyx_v_self->spanning_segment = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":1085
 *         if num_segs == 0:
 *             self.spanning_segment = NullSegment
 *         elif num_segs == 1:             # <<<<<<<<<<<<<<
 *             self.spanning_segment = self._segments[0]
 *         else:
 */
    break;
    default:

    /* "plastid/genomics/roitools.pyx":1088
 *             self.spanning_segment = self._segments[0]
 *         else:
 *             segs = self._segments             # <<<<<<<<<<<<<<
 *             seg0 = segs[0]
 *             self.spanning_segment = GenomicSegment(seg0.chrom,
 */
    __pyx_t_3 = __pyx_v_self->_segments;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_segs = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":1089
 *         else:
 *             segs = self._segments
 *             seg0 = segs[0]             # <<<<<<<<<<<<<<
 *             self.spanning_segment = GenomicSegment(seg0.chrom,
 *                                                    seg0.start,
 */
    if (unlikely(__pyx_v_segs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_segs, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_seg0 = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":1091
 *             seg0 = segs[0]
 *             self.spanning_segment = GenomicSegment(seg0.chrom,
 *                                                    seg0.start,             # <<<<<<<<<<<<<<
 *                                                    segs[-1].end,
 *                                                    seg0.strand)
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_seg0->start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);

    /* "plastid/genomics/roitools.pyx":1092
 *             self.spanning_segment = GenomicSegment(seg0.chrom,
 *                                                    seg0.start,
 *                                                    segs[-1].end,             # <<<<<<<<<<<<<<
 *                                                    seg0.strand)
 * 
 */
    if (unlikely(__pyx_v_segs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_segs, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":1093
 *                                                    seg0.start,
 *                                                    segs[-1].end,
 *                                                    seg0.strand)             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_seg0), __pyx_n_s_strand); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);

    /* "plastid/genomics/roitools.pyx":1090
 *             segs = self._segments
 *             seg0 = segs[0]
 *             self.spanning_segment = GenomicSegment(seg0.chrom,             # <<<<<<<<<<<<<<
 *                                                    seg0.start,
 *                                                    segs[-1].end,
 */
    __pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_seg0->chrom);
    __Pyx_GIVEREF(__pyx_v_seg0->chrom);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_seg0->chrom);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_2);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->spanning_segment);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->spanning_segment));
    __pyx_v_self->spanning_segment = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_2);
    __pyx_t_2 = 0;
    break;
  }

  /* "plastid/genomics/roitools.pyx":1095
 *                                                    seg0.strand)
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef dict _get_inverse_hash(self):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1019
 *             self._set_segments(new_segments)
 * 
 *     cdef bint _set_segments(self, list segments) except False:             # <<<<<<<<<<<<<<
 *         """Set `self._segments` and update position hashes, assuming `segments`
 *         have passed the following criteria:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain._set_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segment);
  __Pyx_XDECREF((PyObject *)__pyx_v_seg0);
  __Pyx_XDECREF((PyObject *)__pyx_v_my_hash);
  __PYX_XDEC_MEMVIEW(&__pyx_v_my_view, 1);
  __Pyx_XDECREF(__pyx_v_segs);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1097
 *         return True
 * 
 *     cdef dict _get_inverse_hash(self):             # <<<<<<<<<<<<<<
 *         """Return dictionary mapping genomic coordinates to |SegmentChain| positions.
 *         If the dictionary `self._inverse_hash` is not populated, it is populated here,
 */

static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain__get_inverse_hash(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_v_ihash = 0;
  __Pyx_memviewslice __pyx_v_my_view = { 0, 0, { 0 }, { 0 }, { 0 } };
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  long __pyx_t_5;
  long __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_inverse_hash", 0);

  /* "plastid/genomics/roitools.pyx":1108
 *         """
 *         cdef:
 *             dict ihash = self._inverse_hash             # <<<<<<<<<<<<<<
 *             long [:] my_view = self._position_hash
 *             long i
 */
  __pyx_t_1 = __pyx_v_self->_inverse_hash;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ihash = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1109
 *         cdef:
 *             dict ihash = self._inverse_hash
 *             long [:] my_view = self._position_hash             # <<<<<<<<<<<<<<
 *             long i
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_long(((PyObject *)__pyx_v_self->_position_hash));
  if (unlikely(!__pyx_t_2.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_my_view = __pyx_t_2;
  __pyx_t_2.memview = NULL;
  __pyx_t_2.data = NULL;

  /* "plastid/genomics/roitools.pyx":1112
 *             long i
 * 
 *         if self.length > 0:             # <<<<<<<<<<<<<<
 *             if len(ihash) > 0:
 *                 return ihash
 */
  __pyx_t_3 = ((__pyx_v_self->length > 0) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":1113
 * 
 *         if self.length > 0:
 *             if len(ihash) > 0:             # <<<<<<<<<<<<<<
 *                 return ihash
 *             else:
 */
    if (unlikely(__pyx_v_ihash == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = PyDict_Size(__pyx_v_ihash); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((__pyx_t_4 > 0) != 0);
    if (__pyx_t_3) {

      /* "plastid/genomics/roitools.pyx":1114
 *         if self.length > 0:
 *             if len(ihash) > 0:
 *                 return ihash             # <<<<<<<<<<<<<<
 *             else:
 *                 for i in range(self.length):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_ihash);
      __pyx_r = __pyx_v_ihash;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":1113
 * 
 *         if self.length > 0:
 *             if len(ihash) > 0:             # <<<<<<<<<<<<<<
 *                 return ihash
 *             else:
 */
    }

    /* "plastid/genomics/roitools.pyx":1116
 *                 return ihash
 *             else:
 *                 for i in range(self.length):             # <<<<<<<<<<<<<<
 *                     ihash[my_view[i]] = i
 * 
 */
    /*else*/ {
      __pyx_t_5 = __pyx_v_self->length;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
        __pyx_v_i = __pyx_t_6;

        /* "plastid/genomics/roitools.pyx":1117
 *             else:
 *                 for i in range(self.length):
 *                     ihash[my_view[i]] = i             # <<<<<<<<<<<<<<
 * 
 *         return ihash
 */
        __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (unlikely(__pyx_v_ihash == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_7 = __pyx_v_i;
        __pyx_t_8 = -1;
        if (__pyx_t_7 < 0) {
          __pyx_t_7 += __pyx_v_my_view.shape[0];
          if (unlikely(__pyx_t_7 < 0)) __pyx_t_8 = 0;
        } else if (unlikely(__pyx_t_7 >= __pyx_v_my_view.shape[0])) __pyx_t_8 = 0;
        if (unlikely(__pyx_t_8 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_8);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_9 = __Pyx_PyInt_From_long((*((long *) ( /* dim=0 */ (__pyx_v_my_view.data + __pyx_t_7 * __pyx_v_my_view.strides[0]) )))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        if (unlikely(PyDict_SetItem(__pyx_v_ihash, __pyx_t_9, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
    }

    /* "plastid/genomics/roitools.pyx":1112
 *             long i
 * 
 *         if self.length > 0:             # <<<<<<<<<<<<<<
 *             if len(ihash) > 0:
 *                 return ihash
 */
  }

  /* "plastid/genomics/roitools.pyx":1119
 *                     ihash[my_view[i]] = i
 * 
 *         return ihash             # <<<<<<<<<<<<<<
 * 
 *     def sort(self): # this should never need to be called, now that _segments and _mask_segments are managed
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ihash);
  __pyx_r = __pyx_v_ihash;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1097
 *         return True
 * 
 *     cdef dict _get_inverse_hash(self):             # <<<<<<<<<<<<<<
 *         """Return dictionary mapping genomic coordinates to |SegmentChain| positions.
 *         If the dictionary `self._inverse_hash` is not populated, it is populated here,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain._get_inverse_hash", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ihash);
  __PYX_XDEC_MEMVIEW(&__pyx_v_my_view, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1121
 *         return ihash
 * 
 *     def sort(self): # this should never need to be called, now that _segments and _mask_segments are managed             # <<<<<<<<<<<<<<
 *         self._segments.sort()
 *         self._mask_segments.sort()
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_3sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_2sort[] = "SegmentChain.sort(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_3sort(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sort (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_2sort(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_2sort(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sort", 0);

  /* "plastid/genomics/roitools.pyx":1122
 * 
 *     def sort(self): # this should never need to be called, now that _segments and _mask_segments are managed
 *         self._segments.sort()             # <<<<<<<<<<<<<<
 *         self._mask_segments.sort()
 * 
 */
  if (unlikely(__pyx_v_self->_segments == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "sort");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_Sort(__pyx_v_self->_segments); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":1123
 *     def sort(self): # this should never need to be called, now that _segments and _mask_segments are managed
 *         self._segments.sort()
 *         self._mask_segments.sort()             # <<<<<<<<<<<<<<
 * 
 *     property chrom:
 */
  if (unlikely(__pyx_v_self->_mask_segments == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "sort");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_Sort(__pyx_v_self->_mask_segments); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":1121
 *         return ihash
 * 
 *     def sort(self): # this should never need to be called, now that _segments and _mask_segments are managed             # <<<<<<<<<<<<<<
 *         self._segments.sort()
 *         self._mask_segments.sort()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.sort", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1127
 *     property chrom:
 *         """Chromosome the SegmentChain resides on"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.spanning_segment.chrom
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_5chrom_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_5chrom_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_5chrom___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_5chrom___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "plastid/genomics/roitools.pyx":1128
 *         """Chromosome the SegmentChain resides on"""
 *         def __get__(self):
 *             return self.spanning_segment.chrom             # <<<<<<<<<<<<<<
 * 
 *     property strand:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->spanning_segment->chrom);
  __pyx_r = __pyx_v_self->spanning_segment->chrom;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1127
 *     property chrom:
 *         """Chromosome the SegmentChain resides on"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.spanning_segment.chrom
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1132
 *     property strand:
 *         """Strand of the SegmentChain"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return strand_to_str(self.spanning_segment.c_strand)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_6strand_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_6strand_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6strand___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6strand___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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);

  /* "plastid/genomics/roitools.pyx":1133
 *         """Strand of the SegmentChain"""
 *         def __get__(self):
 *             return strand_to_str(self.spanning_segment.c_strand)             # <<<<<<<<<<<<<<
 * 
 *     property c_strand:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7plastid_8genomics_8roitools_strand_to_str(__pyx_v_self->spanning_segment->c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1132
 *     property strand:
 *         """Strand of the SegmentChain"""
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return strand_to_str(self.spanning_segment.c_strand)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.strand.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1136
 * 
 *     property c_strand:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.spanning_segment.c_strand
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_8c_strand_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_8c_strand_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8c_strand___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8c_strand___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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);

  /* "plastid/genomics/roitools.pyx":1137
 *     property c_strand:
 *         def __get__(self):
 *             return self.spanning_segment.c_strand             # <<<<<<<<<<<<<<
 * 
 *     property segments:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_v_self->spanning_segment->c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1136
 * 
 *     property c_strand:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.spanning_segment.c_strand
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_strand.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1143
 *         Changing this list will do nothing to `self`.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return copy.deepcopy(self._segments)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_8segments_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_8segments_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8segments___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8segments___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("__get__", 0);

  /* "plastid/genomics/roitools.pyx":1144
 *         """
 *         def __get__(self):
 *             return copy.deepcopy(self._segments)             # <<<<<<<<<<<<<<
 * 
 *     property mask_segments:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->_segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->_segments);
    __Pyx_GIVEREF(__pyx_v_self->_segments);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->_segments);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1143
 *         Changing this list will do nothing to `self`.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return copy.deepcopy(self._segments)
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.segments.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1150
 *         Changing this list will do nothing to the masks in `self`.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return copy.deepcopy(self._mask_segments)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13mask_segments_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13mask_segments_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_13mask_segments___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_13mask_segments___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("__get__", 0);

  /* "plastid/genomics/roitools.pyx":1151
 *         """
 *         def __get__(self):
 *             return copy.deepcopy(self._mask_segments)             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self): # enable pickling
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->_mask_segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->_mask_segments);
    __Pyx_GIVEREF(__pyx_v_self->_mask_segments);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->_mask_segments);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1150
 *         Changing this list will do nothing to the masks in `self`.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return copy.deepcopy(self._mask_segments)
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.mask_segments.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1153
 *             return copy.deepcopy(self._mask_segments)
 * 
 *     def __reduce__(self): # enable pickling             # <<<<<<<<<<<<<<
 *         return (self.__class__,tuple(),self.__getstate__())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_5__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_4__reduce__[] = "SegmentChain.__reduce__(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_5__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4__reduce__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4__reduce__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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);

  /* "plastid/genomics/roitools.pyx":1154
 * 
 *     def __reduce__(self): # enable pickling
 *         return (self.__class__,tuple(),self.__getstate__())             # <<<<<<<<<<<<<<
 * 
 *     def __getstate__(self): # save state for pickling
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyTuple_Type)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_getstate); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; __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(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1153
 *             return copy.deepcopy(self._mask_segments)
 * 
 *     def __reduce__(self): # enable pickling             # <<<<<<<<<<<<<<
 *         return (self.__class__,tuple(),self.__getstate__())
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1156
 *         return (self.__class__,tuple(),self.__getstate__())
 * 
 *     def __getstate__(self): # save state for pickling             # <<<<<<<<<<<<<<
 *         cdef:
 *             list segstrs  = [str(X) for X in self._segments]
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_7__getstate__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_6__getstate__[] = "SegmentChain.__getstate__(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_7__getstate__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6__getstate__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6__getstate__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_v_segstrs = 0;
  PyObject *__pyx_v_maskstrs = 0;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_v_X = 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 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getstate__", 0);

  /* "plastid/genomics/roitools.pyx":1158
 *     def __getstate__(self): # save state for pickling
 *         cdef:
 *             list segstrs  = [str(X) for X in self._segments]             # <<<<<<<<<<<<<<
 *             list maskstrs = [str(X) for X in self._mask_segments]
 *             dict attr = self.attr
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_self->_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __pyx_v_self->_segments; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_X, __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 = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_X);
    __Pyx_GIVEREF(__pyx_v_X);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_X);
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __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_v_segstrs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1159
 *         cdef:
 *             list segstrs  = [str(X) for X in self._segments]
 *             list maskstrs = [str(X) for X in self._mask_segments]             # <<<<<<<<<<<<<<
 *             dict attr = self.attr
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_self->_mask_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __pyx_v_self->_mask_segments; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  for (;;) {
    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 = 1159; __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 = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_X, __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 = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_X);
    __Pyx_GIVEREF(__pyx_v_X);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_X);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_maskstrs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1160
 *             list segstrs  = [str(X) for X in self._segments]
 *             list maskstrs = [str(X) for X in self._mask_segments]
 *             dict attr = self.attr             # <<<<<<<<<<<<<<
 * 
 *         return (segstrs,maskstrs,attr)
 */
  __pyx_t_1 = __pyx_v_self->attr;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1162
 *             dict attr = self.attr
 * 
 *         return (segstrs,maskstrs,attr)             # <<<<<<<<<<<<<<
 * 
 *     def __setstate__(self,state): # revive state from pickling
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_segstrs);
  __Pyx_GIVEREF(__pyx_v_segstrs);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_segstrs);
  __Pyx_INCREF(__pyx_v_maskstrs);
  __Pyx_GIVEREF(__pyx_v_maskstrs);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_maskstrs);
  __Pyx_INCREF(__pyx_v_attr);
  __Pyx_GIVEREF(__pyx_v_attr);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_attr);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1156
 *         return (self.__class__,tuple(),self.__getstate__())
 * 
 *     def __getstate__(self): # save state for pickling             # <<<<<<<<<<<<<<
 *         cdef:
 *             list segstrs  = [str(X) for X in self._segments]
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.__getstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_segstrs);
  __Pyx_XDECREF(__pyx_v_maskstrs);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1164
 *         return (segstrs,maskstrs,attr)
 * 
 *     def __setstate__(self,state): # revive state from pickling             # <<<<<<<<<<<<<<
 *         cdef:
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_9__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_8__setstate__[] = "SegmentChain.__setstate__(self, state)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_9__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8__setstate__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_8__setstate__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_v_segs = 0;
  PyObject *__pyx_v_masks = 0;
  PyObject *__pyx_v_attr = 0;
  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 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "plastid/genomics/roitools.pyx":1166
 *     def __setstate__(self,state): # revive state from pickling
 *         cdef:
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]             # <<<<<<<<<<<<<<
 *             list masks = [GenomicSegment.from_str(X) for X in state[1]]
 *             dict attr = state[2]
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  if (likely(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 = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(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 = 1166; __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 = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        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 = 1166; __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 = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_n_s_from_str); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_X); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); 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_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_X);
      __Pyx_GIVEREF(__pyx_v_X);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_X);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __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_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1166; __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_v_segs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1167
 *         cdef:
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]
 *             list masks = [GenomicSegment.from_str(X) for X in state[1]]             # <<<<<<<<<<<<<<
 *             dict attr = state[2]
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(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 = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(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 = 1167; __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 = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        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 = 1167; __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 = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_n_s_from_str); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_X); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_INCREF(__pyx_v_X);
      __Pyx_GIVEREF(__pyx_v_X);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_X);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __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_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_masks = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1168
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]
 *             list masks = [GenomicSegment.from_str(X) for X in state[1]]
 *             dict attr = state[2]             # <<<<<<<<<<<<<<
 * 
 *         self.attr = attr
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1168; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1170
 *             dict attr = state[2]
 * 
 *         self.attr = attr             # <<<<<<<<<<<<<<
 *         self._set_segments(segs)
 *         self._set_masks(masks)
 */
  __Pyx_INCREF(__pyx_v_attr);
  __Pyx_GIVEREF(__pyx_v_attr);
  __Pyx_GOTREF(__pyx_v_self->attr);
  __Pyx_DECREF(__pyx_v_self->attr);
  __pyx_v_self->attr = __pyx_v_attr;

  /* "plastid/genomics/roitools.pyx":1171
 * 
 *         self.attr = attr
 *         self._set_segments(segs)             # <<<<<<<<<<<<<<
 *         self._set_masks(masks)
 * 
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->_set_segments(__pyx_v_self, __pyx_v_segs); if (unlikely(__pyx_t_9 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":1172
 *         self.attr = attr
 *         self._set_segments(segs)
 *         self._set_masks(masks)             # <<<<<<<<<<<<<<
 * 
 *     def __copy__(self):
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->_set_masks(__pyx_v_self, __pyx_v_masks); if (unlikely(__pyx_t_9 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":1164
 *         return (segstrs,maskstrs,attr)
 * 
 *     def __setstate__(self,state): # revive state from pickling             # <<<<<<<<<<<<<<
 *         cdef:
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]
 */

  /* function exit code */
  __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_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_segs);
  __Pyx_XDECREF(__pyx_v_masks);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1174
 *         self._set_masks(masks)
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         chain2 = SegmentChain()
 *         chain2._set_segments(self._segments)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_11__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_10__copy__[] = "SegmentChain.__copy__(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_11__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__copy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_10__copy__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_10__copy__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_chain2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__copy__", 0);

  /* "plastid/genomics/roitools.pyx":1175
 * 
 *     def __copy__(self):
 *         chain2 = SegmentChain()             # <<<<<<<<<<<<<<
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(self._mask_segments)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_chain2 = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1176
 *     def __copy__(self):
 *         chain2 = SegmentChain()
 *         chain2._set_segments(self._segments)             # <<<<<<<<<<<<<<
 *         chain2._set_masks(self._mask_segments)
 *         chain2.attr = self.attr
 */
  __pyx_t_1 = __pyx_v_self->_segments;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2->__pyx_vtab)->_set_segments(__pyx_v_chain2, ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1177
 *         chain2 = SegmentChain()
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(self._mask_segments)             # <<<<<<<<<<<<<<
 *         chain2.attr = self.attr
 *         return chain2
 */
  __pyx_t_1 = __pyx_v_self->_mask_segments;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2->__pyx_vtab)->_set_masks(__pyx_v_chain2, ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1178
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(self._mask_segments)
 *         chain2.attr = self.attr             # <<<<<<<<<<<<<<
 *         return chain2
 * 
 */
  __pyx_t_1 = __pyx_v_self->attr;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chain2->attr);
  __Pyx_DECREF(__pyx_v_chain2->attr);
  __pyx_v_chain2->attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1179
 *         chain2._set_masks(self._mask_segments)
 *         chain2.attr = self.attr
 *         return chain2             # <<<<<<<<<<<<<<
 * 
 *     def __deepcopy__(self,memo):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_chain2));
  __pyx_r = ((PyObject *)__pyx_v_chain2);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1174
 *         self._set_masks(masks)
 * 
 *     def __copy__(self):             # <<<<<<<<<<<<<<
 *         chain2 = SegmentChain()
 *         chain2._set_segments(self._segments)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__copy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_chain2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1181
 *         return chain2
 * 
 *     def __deepcopy__(self,memo):             # <<<<<<<<<<<<<<
 *         chain2 = SegmentChain()
 *         chain2._set_segments(self._segments)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_12__deepcopy__[] = "SegmentChain.__deepcopy__(self, memo)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__deepcopy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_12__deepcopy__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_memo));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_12__deepcopy__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_chain2 = 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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__deepcopy__", 0);

  /* "plastid/genomics/roitools.pyx":1182
 * 
 *     def __deepcopy__(self,memo):
 *         chain2 = SegmentChain()             # <<<<<<<<<<<<<<
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_chain2 = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1183
 *     def __deepcopy__(self,memo):
 *         chain2 = SegmentChain()
 *         chain2._set_segments(self._segments)             # <<<<<<<<<<<<<<
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))
 *         chain2.attr = copy.deepcopy(self.attr)
 */
  __pyx_t_1 = __pyx_v_self->_segments;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2->__pyx_vtab)->_set_segments(__pyx_v_chain2, ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1184
 *         chain2 = SegmentChain()
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))             # <<<<<<<<<<<<<<
 *         chain2.attr = copy.deepcopy(self.attr)
 *         return chain2
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->_mask_segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_self->_mask_segments);
    __Pyx_GIVEREF(__pyx_v_self->_mask_segments);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_self->_mask_segments);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2->__pyx_vtab)->_set_masks(__pyx_v_chain2, ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1185
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))
 *         chain2.attr = copy.deepcopy(self.attr)             # <<<<<<<<<<<<<<
 *         return chain2
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->attr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_self->attr);
    __Pyx_GIVEREF(__pyx_v_self->attr);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_self->attr);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __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_5); __pyx_t_5 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chain2->attr);
  __Pyx_DECREF(__pyx_v_chain2->attr);
  __pyx_v_chain2->attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1186
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))
 *         chain2.attr = copy.deepcopy(self.attr)
 *         return chain2             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(self, object other, int cmpval):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_chain2));
  __pyx_r = ((PyObject *)__pyx_v_chain2);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1181
 *         return chain2
 * 
 *     def __deepcopy__(self,memo):             # <<<<<<<<<<<<<<
 *         chain2 = SegmentChain()
 *         chain2._set_segments(self._segments)
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.__deepcopy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_chain2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1188
 *         return chain2
 * 
 *     def __richcmp__(self, object other, int cmpval):             # <<<<<<<<<<<<<<
 *         """Test whether `self` and `other` are equal or unequal. Equality is defined as
 *         identity of positions, chromosomes, and strands. Two |SegmentChain| with
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_15__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmpval); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_15__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmpval) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_14__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((int)__pyx_v_cmpval));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_14__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmpval) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __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("__richcmp__", 0);

  /* "plastid/genomics/roitools.pyx":1202
 *         bool
 *         """
 *         if isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return chain_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1203
 *         """
 *         if isinstance(other,SegmentChain):
 *             return chain_richcmp(self,other,cmpval) == true             # <<<<<<<<<<<<<<
 *         elif isinstance(other,GenomicSegment):
 *             return chain_richcmp(self,SegmentChain(other),cmpval) == true
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_self) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other), __pyx_v_cmpval); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1202
 *         bool
 *         """
 *         if isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return chain_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):
 */
  }

  /* "plastid/genomics/roitools.pyx":1204
 *         if isinstance(other,SegmentChain):
 *             return chain_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return chain_richcmp(self,SegmentChain(other),cmpval) == true
 *         else:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":1205
 *             return chain_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):
 *             return chain_richcmp(self,SegmentChain(other),cmpval) == true             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.")
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_self) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_other);
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_chain_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_5), __pyx_v_cmpval); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyBool_FromLong((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1204
 *         if isinstance(other,SegmentChain):
 *             return chain_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return chain_richcmp(self,SegmentChain(other),cmpval) == true
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1207
 *             return chain_richcmp(self,SegmentChain(other),cmpval) == true
 *         else:
 *             raise TypeError("SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.")             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __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 = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1188
 *         return chain2
 * 
 *     def __richcmp__(self, object other, int cmpval):             # <<<<<<<<<<<<<<
 *         """Test whether `self` and `other` are equal or unequal. Equality is defined as
 *         identity of positions, chromosomes, and strands. Two |SegmentChain| with
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1209
 *             raise TypeError("SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.")
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str sout = "<%s segments=%s" % (self.__class__.__name__, len(self._segments))
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_17__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_17__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_16__repr__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_16__repr__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_v_sout = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_span = 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 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "plastid/genomics/roitools.pyx":1211
 *     def __repr__(self):
 *         cdef:
 *             str sout = "<%s segments=%s" % (self.__class__.__name__, len(self._segments))             # <<<<<<<<<<<<<<
 *             GenomicSegment span = self.spanning_segment
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __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_v_self->_segments;
  __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 = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_s_segments_s, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_1))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_sout = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1212
 *         cdef:
 *             str sout = "<%s segments=%s" % (self.__class__.__name__, len(self._segments))
 *             GenomicSegment span = self.spanning_segment             # <<<<<<<<<<<<<<
 * 
 *         if len(self) > 0:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_span = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1214
 *             GenomicSegment span = self.spanning_segment
 * 
 *         if len(self) > 0:             # <<<<<<<<<<<<<<
 *             sout += " bounds=%s:%s-%s(%s)" % (span.chrom,
 *                                               span.start,
 */
  __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((__pyx_t_3 > 0) != 0);
  if (__pyx_t_5) {

    /* "plastid/genomics/roitools.pyx":1216
 *         if len(self) > 0:
 *             sout += " bounds=%s:%s-%s(%s)" % (span.chrom,
 *                                               span.start,             # <<<<<<<<<<<<<<
 *                                               span.end,
 *                                               span.strand)
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_span->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);

    /* "plastid/genomics/roitools.pyx":1217
 *             sout += " bounds=%s:%s-%s(%s)" % (span.chrom,
 *                                               span.start,
 *                                               span.end,             # <<<<<<<<<<<<<<
 *                                               span.strand)
 *             sout += " name=%s" % self.get_name()
 */
    __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_span->end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);

    /* "plastid/genomics/roitools.pyx":1218
 *                                               span.start,
 *                                               span.end,
 *                                               span.strand)             # <<<<<<<<<<<<<<
 *             sout += " name=%s" % self.get_name()
 *         sout += ">"
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_span), __pyx_n_s_strand); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);

    /* "plastid/genomics/roitools.pyx":1215
 * 
 *         if len(self) > 0:
 *             sout += " bounds=%s:%s-%s(%s)" % (span.chrom,             # <<<<<<<<<<<<<<
 *                                               span.start,
 *                                               span.end,
 */
    __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_span->chrom);
    __Pyx_GIVEREF(__pyx_v_span->chrom);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_span->chrom);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_2);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_bounds_s_s_s_s, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_sout, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_6))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF_SET(__pyx_v_sout, ((PyObject*)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":1219
 *                                               span.end,
 *                                               span.strand)
 *             sout += " name=%s" % self.get_name()             # <<<<<<<<<<<<<<
 *         sout += ">"
 *         return sout
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_name_s, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_sout, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_6))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF_SET(__pyx_v_sout, ((PyObject*)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":1214
 *             GenomicSegment span = self.spanning_segment
 * 
 *         if len(self) > 0:             # <<<<<<<<<<<<<<
 *             sout += " bounds=%s:%s-%s(%s)" % (span.chrom,
 *                                               span.start,
 */
  }

  /* "plastid/genomics/roitools.pyx":1220
 *                                               span.strand)
 *             sout += " name=%s" % self.get_name()
 *         sout += ">"             # <<<<<<<<<<<<<<
 *         return sout
 * 
 */
  __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_sout, __pyx_kp_s__12); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF_SET(__pyx_v_sout, ((PyObject*)__pyx_t_6));
  __pyx_t_6 = 0;

  /* "plastid/genomics/roitools.pyx":1221
 *             sout += " name=%s" % self.get_name()
 *         sout += ">"
 *         return sout             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_sout);
  __pyx_r = __pyx_v_sout;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1209
 *             raise TypeError("SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.")
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         cdef:
 *             str sout = "<%s segments=%s" % (self.__class__.__name__, len(self._segments))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sout);
  __Pyx_XDECREF((PyObject *)__pyx_v_span);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1223
 *         return sout
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         """String representation of |SegmentChain|. Inverse of :py:meth:`.from_str`
 *         Chains are represented as:
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_19__str__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_18__str__[] = "String representation of |SegmentChain|. Inverse of :py:meth:`.from_str`\n        Chains are represented as:\n        \n            `'chrom_name:segment1_start-segment1_end^segment2_start-segment2_end^...^(strand)'`\n        \n        Where all coordinates are zero-indexed and half-open. Masked segments\n        are not saved in this representation; nor are attributes in `self.attr`\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_18__str__;
#endif
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_19__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_18__str__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_18__str__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_v_ltmp = NULL;
  PyObject *__pyx_v_stmp = NULL;
  PyObject *__pyx_v_sout = NULL;
  PyObject *__pyx_v_segment = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "plastid/genomics/roitools.pyx":1232
 *         are not saved in this representation; nor are attributes in `self.attr`
 *         """
 *         if len(self) > 0:             # <<<<<<<<<<<<<<
 *             ltmp = ["%s-%s" % (segment.start, segment.end) for segment in self]
 *             stmp = "^".join(ltmp)
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 > 0) != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1233
 *         """
 *         if len(self) > 0:
 *             ltmp = ["%s-%s" % (segment.start, segment.end) for segment in self]             # <<<<<<<<<<<<<<
 *             stmp = "^".join(ltmp)
 *             sout = "%s:%s(%s)" % (self.chrom,stmp,self.strand)
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
      __pyx_t_4 = ((PyObject *)__pyx_v_self); __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)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(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 = 1233; __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 = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          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 = 1233; __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 = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_5(__pyx_t_4);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF_SET(__pyx_v_segment, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_segment, __pyx_n_s_start); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_segment, __pyx_n_s_end); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s_s_2, __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_ltmp = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":1234
 *         if len(self) > 0:
 *             ltmp = ["%s-%s" % (segment.start, segment.end) for segment in self]
 *             stmp = "^".join(ltmp)             # <<<<<<<<<<<<<<
 *             sout = "%s:%s(%s)" % (self.chrom,stmp,self.strand)
 *         else:
 */
    __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__13, __pyx_v_ltmp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_stmp = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":1235
 *             ltmp = ["%s-%s" % (segment.start, segment.end) for segment in self]
 *             stmp = "^".join(ltmp)
 *             sout = "%s:%s(%s)" % (self.chrom,stmp,self.strand)             # <<<<<<<<<<<<<<
 *         else:
 *             sout = "na"
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chrom); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_stmp);
    __Pyx_GIVEREF(__pyx_v_stmp);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_stmp);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_sout = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "plastid/genomics/roitools.pyx":1232
 *         are not saved in this representation; nor are attributes in `self.attr`
 *         """
 *         if len(self) > 0:             # <<<<<<<<<<<<<<
 *             ltmp = ["%s-%s" % (segment.start, segment.end) for segment in self]
 *             stmp = "^".join(ltmp)
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":1237
 *             sout = "%s:%s(%s)" % (self.chrom,stmp,self.strand)
 *         else:
 *             sout = "na"             # <<<<<<<<<<<<<<
 *         return sout
 * 
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_n_s_na);
    __pyx_v_sout = __pyx_n_s_na;
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":1238
 *         else:
 *             sout = "na"
 *         return sout             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self,index):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_sout);
  __pyx_r = __pyx_v_sout;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1223
 *         return sout
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         """String representation of |SegmentChain|. Inverse of :py:meth:`.from_str`
 *         Chains are represented as:
 */

  /* function exit code */
  __pyx_L1_error:;
  __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("plastid.genomics.roitools.SegmentChain.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ltmp);
  __Pyx_XDECREF(__pyx_v_stmp);
  __Pyx_XDECREF(__pyx_v_sout);
  __Pyx_XDECREF(__pyx_v_segment);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1240
 *         return sout
 * 
 *     def __getitem__(self,index):             # <<<<<<<<<<<<<<
 *         """Fetch a |GenomicSegment| from the |SegmentChain|
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_21__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__[] = "Fetch a |GenomicSegment| from the |SegmentChain|\n        \n        Parameters\n        ----------\n        index : int\n            Index of interval to select, from left-to-right in genome\n        \n        Returns\n        -------\n        |GenomicSegment|\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__;
#endif
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_21__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_index));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_index) {
  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);

  /* "plastid/genomics/roitools.pyx":1252
 *         |GenomicSegment|
 *         """
 *         return self._segments[index]             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_self->_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyObject_GetItem(__pyx_v_self->_segments, __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1240
 *         return sout
 * 
 *     def __getitem__(self,index):             # <<<<<<<<<<<<<<
 *         """Fetch a |GenomicSegment| from the |SegmentChain|
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1254
 *         return self._segments[index]
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         """Interation over each |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_23__iter__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_22__iter__[] = "Interation over each |GenomicSegment| in the |SegmentChain|,\n        from left to right on the chromsome";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_22__iter__;
#endif
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_23__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_22__iter__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_22__iter__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("__iter__", 0);

  /* "plastid/genomics/roitools.pyx":1257
 *         """Interation over each |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 *         return iter(self._segments)             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->_segments;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1257; __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;

  /* "plastid/genomics/roitools.pyx":1254
 *         return self._segments[index]
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         """Interation over each |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1259
 *         return iter(self._segments)
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         """Return next |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_25__next__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_24__next__[] = "Return next |GenomicSegment| in the |SegmentChain|,\n        from left to right on the chromsome";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_24__next__;
#endif
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_25__next__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_24__next__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_24__next__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("__next__", 0);

  /* "plastid/genomics/roitools.pyx":1262
 *         """Return next |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 *         return next(self._segments)             # <<<<<<<<<<<<<<
 * 
 *     def next(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_self->_segments;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIter_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __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;

  /* "plastid/genomics/roitools.pyx":1259
 *         return iter(self._segments)
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         """Return next |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1264
 *         return next(self._segments)
 * 
 *     def next(self):             # <<<<<<<<<<<<<<
 *         """Return next |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_27next(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_26next[] = "SegmentChain.next(self)\nReturn next |GenomicSegment| in the |SegmentChain|,\n        from left to right on the chromsome";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_27next(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("next (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_26next(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_26next(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("next", 0);

  /* "plastid/genomics/roitools.pyx":1267
 *         """Return next |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 *         return self.__next__()             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_next); if (unlikely(!__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_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); 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);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1264
 *         return next(self._segments)
 * 
 *     def next(self):             # <<<<<<<<<<<<<<
 *         """Return next |GenomicSegment| in the |SegmentChain|,
 *         from left to right on the chromsome"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.next", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1269
 *         return self.__next__()
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         """Return the number of |GenomicSegments| in the |SegmentChain|"""
 *         return len(self._segments)
 */

/* Python wrapper */
static Py_ssize_t __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_29__len__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_28__len__[] = "Return the number of |GenomicSegments| in the |SegmentChain|";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_28__len__;
#endif
static Py_ssize_t __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_29__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_28__len__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_28__len__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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);

  /* "plastid/genomics/roitools.pyx":1271
 *     def __len__(self):
 *         """Return the number of |GenomicSegments| in the |SegmentChain|"""
 *         return len(self._segments)             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self, object other):
 */
  __pyx_t_1 = __pyx_v_self->_segments;
  __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 = 1271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1269
 *         return self.__next__()
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         """Return the number of |GenomicSegments| in the |SegmentChain|"""
 *         return len(self._segments)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1273
 *         return len(self._segments)
 * 
 *     def __contains__(self, object other):             # <<<<<<<<<<<<<<
 *         """Tests whether |SegmentChain| contains another |SegmentChain|
 *         or |GenomicSegment|. Containment is defined for each type as follows:
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_31__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_30__contains__[] = "Tests whether |SegmentChain| contains another |SegmentChain|\n        or |GenomicSegment|. Containment is defined for each type as follows:\n        \n        =====================   =======================================================\n        **Type of `other`**     **True if**\n        ---------------------   -------------------------------------------------------\n        |SegmentChain|          If `self` and `other` both contain more than one segment,\n                                all segment-segment junctions in `other` must be       \n                                represented in `self`, in identical order, and all\n                                positions covered by `other` must be present in `self`.\n                                If `other` contains one segment, it must be fully\n                                contained by one segment in `self`.                                  \n\n        |GenomicSegment|        `other` must be completely contained        \n                                within one of the segments in `self`                       \n        =====================   =======================================================\n        \n        \n        Parameters\n        ----------\n        other : |SegmentChain| or |GenomicSegment|\n        \tQuery feature\n        \n        \n        Returns\n        -------\n        bool\n        ";
#if CYTHON_COMPILING_IN_CPYTHON
struct wrapperbase __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_30__contains__;
#endif
static int __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_31__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_30__contains__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_30__contains__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other) {
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_v_retval;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  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;
  int __pyx_t_8;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__contains__", 0);

  /* "plastid/genomics/roitools.pyx":1303
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.__contains__(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1304
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):
 *             return self.__contains__(SegmentChain(other))             # <<<<<<<<<<<<<<
 *         elif isinstance(other,SegmentChain):
 *             retval = self.c_contains(other)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contains_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_other);
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __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_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_8;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1303
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.__contains__(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 */
  }

  /* "plastid/genomics/roitools.pyx":1305
 *         if isinstance(other,GenomicSegment):
 *             return self.__contains__(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             retval = self.c_contains(other)
 *             if retval == bool_exception:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":1306
 *             return self.__contains__(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 *             retval = self.c_contains(other)             # <<<<<<<<<<<<<<
 *             if retval == bool_exception:
 *                 raise RuntimeError("SegmentChain.unstranded_overlaps() errored on chain '%s' and object '%s'" % (self,other))
 */
    if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_contains(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other)); if (unlikely(__pyx_t_9 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_retval = __pyx_t_9;

    /* "plastid/genomics/roitools.pyx":1307
 *         elif isinstance(other,SegmentChain):
 *             retval = self.c_contains(other)
 *             if retval == bool_exception:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError("SegmentChain.unstranded_overlaps() errored on chain '%s' and object '%s'" % (self,other))
 *             return retval == true
 */
    __pyx_t_1 = ((__pyx_v_retval == __pyx_e_7plastid_8genomics_8c_common_bool_exception) != 0);
    if (__pyx_t_1) {

      /* "plastid/genomics/roitools.pyx":1308
 *             retval = self.c_contains(other)
 *             if retval == bool_exception:
 *                 raise RuntimeError("SegmentChain.unstranded_overlaps() errored on chain '%s' and object '%s'" % (self,other))             # <<<<<<<<<<<<<<
 *             return retval == true
 *         else:
 */
      __pyx_t_3 = PyTuple_New(2); 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_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_other);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_unstranded_overlaps, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__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 = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__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 = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":1307
 *         elif isinstance(other,SegmentChain):
 *             retval = self.c_contains(other)
 *             if retval == bool_exception:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError("SegmentChain.unstranded_overlaps() errored on chain '%s' and object '%s'" % (self,other))
 *             return retval == true
 */
    }

    /* "plastid/genomics/roitools.pyx":1309
 *             if retval == bool_exception:
 *                 raise RuntimeError("SegmentChain.unstranded_overlaps() errored on chain '%s' and object '%s'" % (self,other))
 *             return retval == true             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("The 'in'/containment operator is only defined for GenomicSegments and SegmentChains")
 */
    __pyx_r = (__pyx_v_retval == __pyx_e_7plastid_8genomics_8c_common_true);
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1305
 *         if isinstance(other,GenomicSegment):
 *             return self.__contains__(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             retval = self.c_contains(other)
 *             if retval == bool_exception:
 */
  }

  /* "plastid/genomics/roitools.pyx":1311
 *             return retval == true
 *         else:
 *             raise TypeError("The 'in'/containment operator is only defined for GenomicSegments and SegmentChains")             # <<<<<<<<<<<<<<
 * 
 *     cdef ExBool c_contains(self, SegmentChain other) except bool_exception:
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; __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[0]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1273
 *         return len(self._segments)
 * 
 *     def __contains__(self, object other):             # <<<<<<<<<<<<<<
 *         """Tests whether |SegmentChain| contains another |SegmentChain|
 *         or |GenomicSegment|. Containment is defined for each type as follows:
 */

  /* function exit code */
  __pyx_L1_error:;
  __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_AddTraceback("plastid.genomics.roitools.SegmentChain.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1313
 *             raise TypeError("The 'in'/containment operator is only defined for GenomicSegments and SegmentChains")
 * 
 *     cdef ExBool c_contains(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         cdef:
 *             set selfpos, opos
 */

static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_contains(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other) {
  PyObject *__pyx_v_selfpos = 0;
  PyObject *__pyx_v_opos = 0;
  PyObject *__pyx_v_myjuncs = 0;
  PyObject *__pyx_v_ojuncs = 0;
  int __pyx_v_i;
  int __pyx_v_mystart;
  int __pyx_v_found;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_sspan = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_ospan = 0;
  PyObject *__pyx_v_segment = NULL;
  PyObject *__pyx_v_myjunc = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  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;
  int __pyx_t_11;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_contains", 0);

  /* "plastid/genomics/roitools.pyx":1319
 *             int i, mystart
 *             bint found
 *             GenomicSegment sspan = self.spanning_segment             # <<<<<<<<<<<<<<
 *             GenomicSegment ospan = other.spanning_segment
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_sspan = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1320
 *             bint found
 *             GenomicSegment sspan = self.spanning_segment
 *             GenomicSegment ospan = other.spanning_segment             # <<<<<<<<<<<<<<
 * 
 *         if len(self) == 0 or len(other) == 0:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_other->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ospan = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1322
 *             GenomicSegment ospan = other.spanning_segment
 * 
 *         if len(self) == 0 or len(other) == 0:             # <<<<<<<<<<<<<<
 *             return false
 *         elif sspan.chrom != ospan.chrom:
 */
  __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_other)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1323
 * 
 *         if len(self) == 0 or len(other) == 0:
 *             return false             # <<<<<<<<<<<<<<
 *         elif sspan.chrom != ospan.chrom:
 *             return false
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1322
 *             GenomicSegment ospan = other.spanning_segment
 * 
 *         if len(self) == 0 or len(other) == 0:             # <<<<<<<<<<<<<<
 *             return false
 *         elif sspan.chrom != ospan.chrom:
 */
  }

  /* "plastid/genomics/roitools.pyx":1324
 *         if len(self) == 0 or len(other) == 0:
 *             return false
 *         elif sspan.chrom != ospan.chrom:             # <<<<<<<<<<<<<<
 *             return false
 *         elif sspan.c_strand != ospan.c_strand:
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_sspan->chrom, __pyx_v_ospan->chrom, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":1325
 *             return false
 *         elif sspan.chrom != ospan.chrom:
 *             return false             # <<<<<<<<<<<<<<
 *         elif sspan.c_strand != ospan.c_strand:
 *             return false
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1324
 *         if len(self) == 0 or len(other) == 0:
 *             return false
 *         elif sspan.chrom != ospan.chrom:             # <<<<<<<<<<<<<<
 *             return false
 *         elif sspan.c_strand != ospan.c_strand:
 */
  }

  /* "plastid/genomics/roitools.pyx":1326
 *         elif sspan.chrom != ospan.chrom:
 *             return false
 *         elif sspan.c_strand != ospan.c_strand:             # <<<<<<<<<<<<<<
 *             return false
 *         elif other.length > self.length:
 */
  __pyx_t_4 = ((__pyx_v_sspan->c_strand != __pyx_v_ospan->c_strand) != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":1327
 *             return false
 *         elif sspan.c_strand != ospan.c_strand:
 *             return false             # <<<<<<<<<<<<<<
 *         elif other.length > self.length:
 *             return false
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1326
 *         elif sspan.chrom != ospan.chrom:
 *             return false
 *         elif sspan.c_strand != ospan.c_strand:             # <<<<<<<<<<<<<<
 *             return false
 *         elif other.length > self.length:
 */
  }

  /* "plastid/genomics/roitools.pyx":1328
 *         elif sspan.c_strand != ospan.c_strand:
 *             return false
 *         elif other.length > self.length:             # <<<<<<<<<<<<<<
 *             return false
 *         elif len(other) == 1:
 */
  __pyx_t_4 = ((__pyx_v_other->length > __pyx_v_self->length) != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":1329
 *             return false
 *         elif other.length > self.length:
 *             return false             # <<<<<<<<<<<<<<
 *         elif len(other) == 1:
 *             for segment in self:
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1328
 *         elif sspan.c_strand != ospan.c_strand:
 *             return false
 *         elif other.length > self.length:             # <<<<<<<<<<<<<<
 *             return false
 *         elif len(other) == 1:
 */
  }

  /* "plastid/genomics/roitools.pyx":1330
 *         elif other.length > self.length:
 *             return false
 *         elif len(other) == 1:             # <<<<<<<<<<<<<<
 *             for segment in self:
 *                 if segment.contains(other[0]):
 */
  __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_other)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((__pyx_t_3 == 1) != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":1331
 *             return false
 *         elif len(other) == 1:
 *             for segment in self:             # <<<<<<<<<<<<<<
 *                 if segment.contains(other[0]):
 *                     return true
 */
    if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
      __pyx_t_1 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_5(__pyx_t_1);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF_SET(__pyx_v_segment, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "plastid/genomics/roitools.pyx":1332
 *         elif len(other) == 1:
 *             for segment in self:
 *                 if segment.contains(other[0]):             # <<<<<<<<<<<<<<
 *                     return true
 *             return false
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_segment, __pyx_n_s_contains); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_GetItemInt(((PyObject *)__pyx_v_other), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_4) {

        /* "plastid/genomics/roitools.pyx":1333
 *             for segment in self:
 *                 if segment.contains(other[0]):
 *                     return true             # <<<<<<<<<<<<<<
 *             return false
 *         else:
 */
        __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;

        /* "plastid/genomics/roitools.pyx":1332
 *         elif len(other) == 1:
 *             for segment in self:
 *                 if segment.contains(other[0]):             # <<<<<<<<<<<<<<
 *                     return true
 *             return false
 */
      }

      /* "plastid/genomics/roitools.pyx":1331
 *             return false
 *         elif len(other) == 1:
 *             for segment in self:             # <<<<<<<<<<<<<<
 *                 if segment.contains(other[0]):
 *                     return true
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1334
 *                 if segment.contains(other[0]):
 *                     return true
 *             return false             # <<<<<<<<<<<<<<
 *         else:
 *             selfpos = self.c_get_position_set()
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1330
 *         elif other.length > self.length:
 *             return false
 *         elif len(other) == 1:             # <<<<<<<<<<<<<<
 *             for segment in self:
 *                 if segment.contains(other[0]):
 */
  }

  /* "plastid/genomics/roitools.pyx":1336
 *             return false
 *         else:
 *             selfpos = self.c_get_position_set()             # <<<<<<<<<<<<<<
 *             opos    = other.c_get_position_set()
 * 
 */
  /*else*/ {
    __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_position_set(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_selfpos = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1337
 *         else:
 *             selfpos = self.c_get_position_set()
 *             opos    = other.c_get_position_set()             # <<<<<<<<<<<<<<
 * 
 *             if opos & selfpos == opos:
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other->__pyx_vtab)->c_get_position_set(__pyx_v_other); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_opos = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1339
 *             opos    = other.c_get_position_set()
 * 
 *             if opos & selfpos == opos:             # <<<<<<<<<<<<<<
 *                 myjuncs = self.get_junctions()
 *                 ojuncs  = other.get_junctions()
 */
    __pyx_t_1 = PyNumber_And(__pyx_v_opos, __pyx_v_selfpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_v_opos, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_4) {

      /* "plastid/genomics/roitools.pyx":1340
 * 
 *             if opos & selfpos == opos:
 *                 myjuncs = self.get_junctions()             # <<<<<<<<<<<<<<
 *                 ojuncs  = other.get_junctions()
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_junctions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (__pyx_t_7) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(PyList_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_myjuncs = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "plastid/genomics/roitools.pyx":1341
 *             if opos & selfpos == opos:
 *                 myjuncs = self.get_junctions()
 *                 ojuncs  = other.get_junctions()             # <<<<<<<<<<<<<<
 * 
 *                 found = False
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_get_junctions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (__pyx_t_7) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(PyList_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_ojuncs = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "plastid/genomics/roitools.pyx":1343
 *                 ojuncs  = other.get_junctions()
 * 
 *                 found = False             # <<<<<<<<<<<<<<
 *                 for i, myjunc in enumerate(myjuncs):
 *                     if ojuncs[0] == myjunc:
 */
      __pyx_v_found = 0;

      /* "plastid/genomics/roitools.pyx":1344
 * 
 *                 found = False
 *                 for i, myjunc in enumerate(myjuncs):             # <<<<<<<<<<<<<<
 *                     if ojuncs[0] == myjunc:
 *                         mystart = i
 */
      __pyx_t_11 = 0;
      __pyx_t_6 = __pyx_v_myjuncs; __Pyx_INCREF(__pyx_t_6); __pyx_t_3 = 0;
      for (;;) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_XDECREF_SET(__pyx_v_myjunc, __pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_v_i = __pyx_t_11;
        __pyx_t_11 = (__pyx_t_11 + 1);

        /* "plastid/genomics/roitools.pyx":1345
 *                 found = False
 *                 for i, myjunc in enumerate(myjuncs):
 *                     if ojuncs[0] == myjunc:             # <<<<<<<<<<<<<<
 *                         mystart = i
 *                         found   = True
 */
        if (unlikely(__pyx_v_ojuncs == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_ojuncs, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_v_myjunc, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (__pyx_t_4) {

          /* "plastid/genomics/roitools.pyx":1346
 *                 for i, myjunc in enumerate(myjuncs):
 *                     if ojuncs[0] == myjunc:
 *                         mystart = i             # <<<<<<<<<<<<<<
 *                         found   = True
 *                         break
 */
          __pyx_v_mystart = __pyx_v_i;

          /* "plastid/genomics/roitools.pyx":1347
 *                     if ojuncs[0] == myjunc:
 *                         mystart = i
 *                         found   = True             # <<<<<<<<<<<<<<
 *                         break
 *             else:
 */
          __pyx_v_found = 1;

          /* "plastid/genomics/roitools.pyx":1348
 *                         mystart = i
 *                         found   = True
 *                         break             # <<<<<<<<<<<<<<
 *             else:
 *                 return false
 */
          goto __pyx_L11_break;

          /* "plastid/genomics/roitools.pyx":1345
 *                 found = False
 *                 for i, myjunc in enumerate(myjuncs):
 *                     if ojuncs[0] == myjunc:             # <<<<<<<<<<<<<<
 *                         mystart = i
 *                         found   = True
 */
        }

        /* "plastid/genomics/roitools.pyx":1344
 * 
 *                 found = False
 *                 for i, myjunc in enumerate(myjuncs):             # <<<<<<<<<<<<<<
 *                     if ojuncs[0] == myjunc:
 *                         mystart = i
 */
      }
      __pyx_L11_break:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "plastid/genomics/roitools.pyx":1339
 *             opos    = other.c_get_position_set()
 * 
 *             if opos & selfpos == opos:             # <<<<<<<<<<<<<<
 *                 myjuncs = self.get_junctions()
 *                 ojuncs  = other.get_junctions()
 */
      goto __pyx_L9;
    }

    /* "plastid/genomics/roitools.pyx":1350
 *                         break
 *             else:
 *                 return false             # <<<<<<<<<<<<<<
 * 
 *             if found == True:
 */
    /*else*/ {
      __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
      goto __pyx_L0;
    }
    __pyx_L9:;

    /* "plastid/genomics/roitools.pyx":1352
 *                 return false
 * 
 *             if found == True:             # <<<<<<<<<<<<<<
 *                 return true if ojuncs == myjuncs[mystart:mystart+len(ojuncs)] else false
 *             else:
 */
    __pyx_t_4 = ((__pyx_v_found == 1) != 0);
    if (__pyx_t_4) {

      /* "plastid/genomics/roitools.pyx":1353
 * 
 *             if found == True:
 *                 return true if ojuncs == myjuncs[mystart:mystart+len(ojuncs)] else false             # <<<<<<<<<<<<<<
 *             else:
 *                 return false
 */
      if (unlikely(__pyx_v_myjuncs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(__pyx_v_ojuncs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_3 = PyList_GET_SIZE(__pyx_v_ojuncs); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = __Pyx_PyList_GetSlice(__pyx_v_myjuncs, __pyx_v_mystart, (__pyx_v_mystart + __pyx_t_3)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_ojuncs, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_4) {
        __pyx_t_12 = __pyx_e_7plastid_8genomics_8c_common_true;
      } else {
        __pyx_t_12 = __pyx_e_7plastid_8genomics_8c_common_false;
      }
      __pyx_r = __pyx_t_12;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":1352
 *                 return false
 * 
 *             if found == True:             # <<<<<<<<<<<<<<
 *                 return true if ojuncs == myjuncs[mystart:mystart+len(ojuncs)] else false
 *             else:
 */
    }

    /* "plastid/genomics/roitools.pyx":1355
 *                 return true if ojuncs == myjuncs[mystart:mystart+len(ojuncs)] else false
 *             else:
 *                 return false             # <<<<<<<<<<<<<<
 * 
 * 
 */
    /*else*/ {
      __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
      goto __pyx_L0;
    }
  }

  /* "plastid/genomics/roitools.pyx":1313
 *             raise TypeError("The 'in'/containment operator is only defined for GenomicSegments and SegmentChains")
 * 
 *     cdef ExBool c_contains(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         cdef:
 *             set selfpos, opos
 */

  /* function exit code */
  __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_AddTraceback("plastid.genomics.roitools.SegmentChain.c_contains", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_bool_exception;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_selfpos);
  __Pyx_XDECREF(__pyx_v_opos);
  __Pyx_XDECREF(__pyx_v_myjuncs);
  __Pyx_XDECREF(__pyx_v_ojuncs);
  __Pyx_XDECREF((PyObject *)__pyx_v_sspan);
  __Pyx_XDECREF((PyObject *)__pyx_v_ospan);
  __Pyx_XDECREF(__pyx_v_segment);
  __Pyx_XDECREF(__pyx_v_myjunc);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1358
 * 
 * 
 *     def shares_segments_with(self, object other):             # <<<<<<<<<<<<<<
 *         """Returns a list of |GenomicSegment| that are shared between `self` and `other`
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_33shares_segments_with(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_32shares_segments_with[] = "SegmentChain.shares_segments_with(self, other)\nReturns a list of |GenomicSegment| that are shared between `self` and `other`\n           \n        Parameters\n        ----------\n        other : |SegmentChain| or |GenomicSegment|\n        \tQuery feature\n        \n        Returns\n        -------\n        list\n            List of |GenomicSegments| common to `self` and `other`\n        \n        Raises\n        ------\n        TypeError\n            if `other` is not a |GenomicSegment| or |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_33shares_segments_with(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("shares_segments_with (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_32shares_segments_with(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_32shares_segments_with(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  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("shares_segments_with", 0);

  /* "plastid/genomics/roitools.pyx":1376
 *             if `other` is not a |GenomicSegment| or |SegmentChain|
 *         """
 *         if isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_shares_segments_with(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1377
 *         """
 *         if isinstance(other,GenomicSegment):
 *             return self.c_shares_segments_with(SegmentChain(other))             # <<<<<<<<<<<<<<
 *         elif isinstance(other,SegmentChain):
 *             return self.c_shares_segments_with(other)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_shares_segments_with(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1376
 *             if `other` is not a |GenomicSegment| or |SegmentChain|
 *         """
 *         if isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_shares_segments_with(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 */
  }

  /* "plastid/genomics/roitools.pyx":1378
 *         if isinstance(other,GenomicSegment):
 *             return self.c_shares_segments_with(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return self.c_shares_segments_with(other)
 *         else:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":1379
 *             return self.c_shares_segments_with(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 *             return self.c_shares_segments_with(other)             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("SegmentChain.shares_segments_with() is defined only for GenomicSegments and SegmentChains. Found %s." % type(other))
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_shares_segments_with(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1378
 *         if isinstance(other,GenomicSegment):
 *             return self.c_shares_segments_with(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return self.c_shares_segments_with(other)
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1381
 *             return self.c_shares_segments_with(other)
 *         else:
 *             raise TypeError("SegmentChain.shares_segments_with() is defined only for GenomicSegments and SegmentChains. Found %s." % type(other))             # <<<<<<<<<<<<<<
 * 
 *     cdef list c_shares_segments_with(self, SegmentChain other):
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_shares_segments_wit, ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1381; __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 = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__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 = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1358
 * 
 * 
 *     def shares_segments_with(self, object other):             # <<<<<<<<<<<<<<
 *         """Returns a list of |GenomicSegment| that are shared between `self` and `other`
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.shares_segments_with", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1383
 *             raise TypeError("SegmentChain.shares_segments_with() is defined only for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef list c_shares_segments_with(self, SegmentChain other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             list shared
 */

static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_shares_segments_with(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other) {
  PyObject *__pyx_v_shared = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_segment = 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;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_shares_segments_with", 0);

  /* "plastid/genomics/roitools.pyx":1387
 *             list shared
 *             GenomicSegment segment
 *         if self.chrom != other.chrom or self.c_strand != other.c_strand:             # <<<<<<<<<<<<<<
 *             return []
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chrom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_chrom); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __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_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __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 = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":1388
 *             GenomicSegment segment
 *         if self.chrom != other.chrom or self.c_strand != other.c_strand:
 *             return []             # <<<<<<<<<<<<<<
 *         else:
 *             shared = []
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1387
 *             list shared
 *             GenomicSegment segment
 *         if self.chrom != other.chrom or self.c_strand != other.c_strand:             # <<<<<<<<<<<<<<
 *             return []
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1390
 *             return []
 *         else:
 *             shared = []             # <<<<<<<<<<<<<<
 *             for segment in other:
 *                 if segment in self._segments:
 */
  /*else*/ {
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_shared = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":1391
 *         else:
 *             shared = []
 *             for segment in other:             # <<<<<<<<<<<<<<
 *                 if segment in self._segments:
 *                     shared.append(segment)
 */
    if (likely(PyList_CheckExact(((PyObject *)__pyx_v_other))) || PyTuple_CheckExact(((PyObject *)__pyx_v_other))) {
      __pyx_t_2 = ((PyObject *)__pyx_v_other); __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(((PyObject *)__pyx_v_other)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_7(__pyx_t_2);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF_SET(__pyx_v_segment, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "plastid/genomics/roitools.pyx":1392
 *             shared = []
 *             for segment in other:
 *                 if segment in self._segments:             # <<<<<<<<<<<<<<
 *                     shared.append(segment)
 *             return shared
 */
      __pyx_t_1 = (__Pyx_PySequence_ContainsTF(((PyObject *)__pyx_v_segment), __pyx_v_self->_segments, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = (__pyx_t_1 != 0);
      if (__pyx_t_5) {

        /* "plastid/genomics/roitools.pyx":1393
 *             for segment in other:
 *                 if segment in self._segments:
 *                     shared.append(segment)             # <<<<<<<<<<<<<<
 *             return shared
 * 
 */
        __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_shared, ((PyObject *)__pyx_v_segment)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "plastid/genomics/roitools.pyx":1392
 *             shared = []
 *             for segment in other:
 *                 if segment in self._segments:             # <<<<<<<<<<<<<<
 *                     shared.append(segment)
 *             return shared
 */
      }

      /* "plastid/genomics/roitools.pyx":1391
 *         else:
 *             shared = []
 *             for segment in other:             # <<<<<<<<<<<<<<
 *                 if segment in self._segments:
 *                     shared.append(segment)
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":1394
 *                 if segment in self._segments:
 *                     shared.append(segment)
 *             return shared             # <<<<<<<<<<<<<<
 * 
 *     def  unstranded_overlaps(self, object other):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_shared);
    __pyx_r = __pyx_v_shared;
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":1383
 *             raise TypeError("SegmentChain.shares_segments_with() is defined only for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef list c_shares_segments_with(self, SegmentChain other):             # <<<<<<<<<<<<<<
 *         cdef:
 *             list shared
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_shares_segments_with", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_shared);
  __Pyx_XDECREF((PyObject *)__pyx_v_segment);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1396
 *             return shared
 * 
 *     def  unstranded_overlaps(self, object other):             # <<<<<<<<<<<<<<
 *         """Return `True` if `self` and `other` share genomic positions
 *         on the same chromosome, regardless of their strands
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_35unstranded_overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_34unstranded_overlaps[] = "SegmentChain.unstranded_overlaps(self, other)\nReturn `True` if `self` and `other` share genomic positions\n        on the same chromosome, regardless of their strands\n        \n        Parameters\n        ----------\n        other : |SegmentChain| or |GenomicSegment|\n        \tQuery feature\n         \n        Returns\n        -------\n        bool\n            `True` if `self` and `other` share genomic positions on the same\n            chromosome, False otherwise. Strands of `self` and `other` need\n            not match\n            \n        Raises\n        ------\n        TypeError\n            if `other` is not a |GenomicSegment| or |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_35unstranded_overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("unstranded_overlaps (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_34unstranded_overlaps(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_34unstranded_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __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("unstranded_overlaps", 0);

  /* "plastid/genomics/roitools.pyx":1418
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return self.c_unstranded_overlaps(other) == true
 *         elif isinstance(other,GenomicSegment):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1419
 *         cdef ExBool retval
 *         if isinstance(other,SegmentChain):
 *             return self.c_unstranded_overlaps(other) == true             # <<<<<<<<<<<<<<
 *         elif isinstance(other,GenomicSegment):
 *             return self.c_unstranded_overlaps(SegmentChain(other)) == true
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_unstranded_overlaps(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other)); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1418
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return self.c_unstranded_overlaps(other) == true
 *         elif isinstance(other,GenomicSegment):
 */
  }

  /* "plastid/genomics/roitools.pyx":1420
 *         if isinstance(other,SegmentChain):
 *             return self.c_unstranded_overlaps(other) == true
 *         elif isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_unstranded_overlaps(SegmentChain(other)) == true
 *         else:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":1421
 *             return self.c_unstranded_overlaps(other) == true
 *         elif isinstance(other,GenomicSegment):
 *             return self.c_unstranded_overlaps(SegmentChain(other)) == true             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("SegmentChain.unstranded_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_other);
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_unstranded_overlaps(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_5)); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyBool_FromLong((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1420
 *         if isinstance(other,SegmentChain):
 *             return self.c_unstranded_overlaps(other) == true
 *         elif isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_unstranded_overlaps(SegmentChain(other)) == true
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1423
 *             return self.c_unstranded_overlaps(SegmentChain(other)) == true
 *         else:
 *             raise TypeError("SegmentChain.unstranded_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))             # <<<<<<<<<<<<<<
 * 
 *     cdef ExBool c_unstranded_overlaps(self, SegmentChain other) except bool_exception:
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_unstranded_overlaps_2, ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1396
 *             return shared
 * 
 *     def  unstranded_overlaps(self, object other):             # <<<<<<<<<<<<<<
 *         """Return `True` if `self` and `other` share genomic positions
 *         on the same chromosome, regardless of their strands
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.unstranded_overlaps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1425
 *             raise TypeError("SegmentChain.unstranded_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef ExBool c_unstranded_overlaps(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         cdef:
 *             set o_pos, my_pos
 */

static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_unstranded_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other) {
  PyObject *__pyx_v_o_pos = 0;
  PyObject *__pyx_v_my_pos = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_r;
  __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_unstranded_overlaps", 0);

  /* "plastid/genomics/roitools.pyx":1428
 *         cdef:
 *             set o_pos, my_pos
 *         if self.chrom != other.chrom:             # <<<<<<<<<<<<<<
 *             return false
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chrom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_chrom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __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 = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":1429
 *             set o_pos, my_pos
 *         if self.chrom != other.chrom:
 *             return false             # <<<<<<<<<<<<<<
 *         else:
 *             my_pos = self.c_get_position_set()
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1428
 *         cdef:
 *             set o_pos, my_pos
 *         if self.chrom != other.chrom:             # <<<<<<<<<<<<<<
 *             return false
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1431
 *             return false
 *         else:
 *             my_pos = self.c_get_position_set()             # <<<<<<<<<<<<<<
 *             o_pos  = other.c_get_position_set()
 * 
 */
  /*else*/ {
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_position_set(__pyx_v_self); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_my_pos = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":1432
 *         else:
 *             my_pos = self.c_get_position_set()
 *             o_pos  = other.c_get_position_set()             # <<<<<<<<<<<<<<
 * 
 *         if len(my_pos & o_pos) > 0:
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other->__pyx_vtab)->c_get_position_set(__pyx_v_other); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_o_pos = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
  }

  /* "plastid/genomics/roitools.pyx":1434
 *             o_pos  = other.c_get_position_set()
 * 
 *         if len(my_pos & o_pos) > 0:             # <<<<<<<<<<<<<<
 *             return true
 * 
 */
  __pyx_t_3 = PyNumber_And(__pyx_v_my_pos, __pyx_v_o_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PySet_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = ((__pyx_t_5 > 0) != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":1435
 * 
 *         if len(my_pos & o_pos) > 0:
 *             return true             # <<<<<<<<<<<<<<
 * 
 *         return false
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1434
 *             o_pos  = other.c_get_position_set()
 * 
 *         if len(my_pos & o_pos) > 0:             # <<<<<<<<<<<<<<
 *             return true
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":1437
 *             return true
 * 
 *         return false             # <<<<<<<<<<<<<<
 * 
 *     def overlaps(self, object other):
 */
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1425
 *             raise TypeError("SegmentChain.unstranded_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef ExBool c_unstranded_overlaps(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         cdef:
 *             set o_pos, my_pos
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_unstranded_overlaps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_bool_exception;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_o_pos);
  __Pyx_XDECREF(__pyx_v_my_pos);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1439
 *         return false
 * 
 *     def overlaps(self, object other):             # <<<<<<<<<<<<<<
 *         """Return `True` if `self` and `other` share genomic positions on the same strand
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_37overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_36overlaps[] = "SegmentChain.overlaps(self, other)\nReturn `True` if `self` and `other` share genomic positions on the same strand\n        \n        Parameters\n        ----------\n        other : |SegmentChain| or |GenomicSegment|\n        \tQuery feature\n        \n        Returns\n        -------\n        bool\n            `True` if `self` and `other` share genomic positions on the same\n            chromosome and strand; False otherwise.\n        \n        Raises\n        ------\n        TypeError\n            if `other` is not a |GenomicSegment| or |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_37overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("overlaps (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_36overlaps(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_36overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("overlaps", 0);

  /* "plastid/genomics/roitools.pyx":1459
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_overlaps(SegmentChain(other)) == true
 *         elif isinstance(other,SegmentChain):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1460
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):
 *             return self.c_overlaps(SegmentChain(other)) == true             # <<<<<<<<<<<<<<
 *         elif isinstance(other,SegmentChain):
 *             return self.c_overlaps(other) == true
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_overlaps(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_4)); if (unlikely(__pyx_t_5 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_t_5 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1459
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_overlaps(SegmentChain(other)) == true
 *         elif isinstance(other,SegmentChain):
 */
  }

  /* "plastid/genomics/roitools.pyx":1461
 *         if isinstance(other,GenomicSegment):
 *             return self.c_overlaps(SegmentChain(other)) == true
 *         elif isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return self.c_overlaps(other) == true
 *         else:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":1462
 *             return self.c_overlaps(SegmentChain(other)) == true
 *         elif isinstance(other,SegmentChain):
 *             return self.c_overlaps(other) == true             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("SegmentChain.overlaps() is defined only for GenomicSegments and SegmentChains. Found %s." % type(other))
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_overlaps(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other)); if (unlikely(__pyx_t_5 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_t_5 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1461
 *         if isinstance(other,GenomicSegment):
 *             return self.c_overlaps(SegmentChain(other)) == true
 *         elif isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return self.c_overlaps(other) == true
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1464
 *             return self.c_overlaps(other) == true
 *         else:
 *             raise TypeError("SegmentChain.overlaps() is defined only for GenomicSegments and SegmentChains. Found %s." % type(other))             # <<<<<<<<<<<<<<
 * 
 *     cdef ExBool c_overlaps(self, SegmentChain other) except bool_exception:
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_overlaps_is_defined, ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __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 = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__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 = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1439
 *         return false
 * 
 *     def overlaps(self, object other):             # <<<<<<<<<<<<<<
 *         """Return `True` if `self` and `other` share genomic positions on the same strand
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.overlaps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1466
 *             raise TypeError("SegmentChain.overlaps() is defined only for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef ExBool c_overlaps(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         cdef:
 *             Strand sstrand = self.c_strand
 */

static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other) {
  CYTHON_UNUSED enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_sstrand;
  CYTHON_UNUSED enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_ostrand;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_t_2;
  int __pyx_t_3;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_overlaps", 0);

  /* "plastid/genomics/roitools.pyx":1468
 *     cdef ExBool c_overlaps(self, SegmentChain other) except bool_exception:
 *         cdef:
 *             Strand sstrand = self.c_strand             # <<<<<<<<<<<<<<
 *             Strand ostrand = other.c_strand
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((enum __pyx_t_7plastid_8genomics_8c_common_Strand)__Pyx_PyInt_As_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_t_1)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_sstrand = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":1469
 *         cdef:
 *             Strand sstrand = self.c_strand
 *             Strand ostrand = other.c_strand             # <<<<<<<<<<<<<<
 * 
 *         if self.c_unstranded_overlaps(other) == true and self.c_strand & other.c_strand == other.c_strand:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((enum __pyx_t_7plastid_8genomics_8c_common_Strand)__Pyx_PyInt_As_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_t_1)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ostrand = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":1471
 *             Strand ostrand = other.c_strand
 * 
 *         if self.c_unstranded_overlaps(other) == true and self.c_strand & other.c_strand == other.c_strand:             # <<<<<<<<<<<<<<
 *             return true
 * 
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_unstranded_overlaps(__pyx_v_self, __pyx_v_other); if (unlikely(__pyx_t_4 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((__pyx_t_4 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_And(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; __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_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":1472
 * 
 *         if self.c_unstranded_overlaps(other) == true and self.c_strand & other.c_strand == other.c_strand:
 *             return true             # <<<<<<<<<<<<<<
 * 
 *         return false
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1471
 *             Strand ostrand = other.c_strand
 * 
 *         if self.c_unstranded_overlaps(other) == true and self.c_strand & other.c_strand == other.c_strand:             # <<<<<<<<<<<<<<
 *             return true
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":1474
 *             return true
 * 
 *         return false             # <<<<<<<<<<<<<<
 * 
 *     def antisense_overlaps(self, object other):
 */
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1466
 *             raise TypeError("SegmentChain.overlaps() is defined only for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef ExBool c_overlaps(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         cdef:
 *             Strand sstrand = self.c_strand
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_overlaps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_bool_exception;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1476
 *         return false
 * 
 *     def antisense_overlaps(self, object other):             # <<<<<<<<<<<<<<
 *         """Returns `True` if `self` and `other` share genomic positions on opposite strands
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_39antisense_overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_38antisense_overlaps[] = "SegmentChain.antisense_overlaps(self, other)\nReturns `True` if `self` and `other` share genomic positions on opposite strands\n        \n        Parameters\n        ----------\n        other : |SegmentChain| or |GenomicSegment|\n        \tQuery feature\n         \n        Returns\n        -------\n        bool\n            `True` if `self` and `other` share genomic positions on the same\n            chromosome but opposite strand; False otherwise.\n                    \n        Raises\n        ------\n        TypeError\n            if `other` is not a |GenomicSegment| or |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_39antisense_overlaps(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("antisense_overlaps (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_38antisense_overlaps(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_38antisense_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other) {
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_v_retval;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("antisense_overlaps", 0);

  /* "plastid/genomics/roitools.pyx":1496
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_antisense_overlaps(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1497
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):
 *             return self.c_antisense_overlaps(SegmentChain(other))             # <<<<<<<<<<<<<<
 *         elif isinstance(other,SegmentChain):
 *             retval = self.c_antisense_overlaps(other)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_other);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_antisense_overlaps(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_4)); if (unlikely(__pyx_t_5 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_ExBool(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1496
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_antisense_overlaps(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 */
  }

  /* "plastid/genomics/roitools.pyx":1498
 *         if isinstance(other,GenomicSegment):
 *             return self.c_antisense_overlaps(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             retval = self.c_antisense_overlaps(other)
 *             if retval == bool_exception:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":1499
 *             return self.c_antisense_overlaps(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):
 *             retval = self.c_antisense_overlaps(other)             # <<<<<<<<<<<<<<
 *             if retval == bool_exception:
 *                 raise RuntimeError("SegmentChain.antisense_overlaps() errored on chain '%s' and object '%s'" % (self,other))
 */
    if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_antisense_overlaps(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other)); if (unlikely(__pyx_t_5 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_retval = __pyx_t_5;

    /* "plastid/genomics/roitools.pyx":1500
 *         elif isinstance(other,SegmentChain):
 *             retval = self.c_antisense_overlaps(other)
 *             if retval == bool_exception:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError("SegmentChain.antisense_overlaps() errored on chain '%s' and object '%s'" % (self,other))
 *             return retval == true
 */
    __pyx_t_1 = ((__pyx_v_retval == __pyx_e_7plastid_8genomics_8c_common_bool_exception) != 0);
    if (__pyx_t_1) {

      /* "plastid/genomics/roitools.pyx":1501
 *             retval = self.c_antisense_overlaps(other)
 *             if retval == bool_exception:
 *                 raise RuntimeError("SegmentChain.antisense_overlaps() errored on chain '%s' and object '%s'" % (self,other))             # <<<<<<<<<<<<<<
 *             return retval == true
 *         else:
 */
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_other);
      __Pyx_GIVEREF(__pyx_v_other);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_other);
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_antisense_overlaps, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __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 = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__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 = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":1500
 *         elif isinstance(other,SegmentChain):
 *             retval = self.c_antisense_overlaps(other)
 *             if retval == bool_exception:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError("SegmentChain.antisense_overlaps() errored on chain '%s' and object '%s'" % (self,other))
 *             return retval == true
 */
    }

    /* "plastid/genomics/roitools.pyx":1502
 *             if retval == bool_exception:
 *                 raise RuntimeError("SegmentChain.antisense_overlaps() errored on chain '%s' and object '%s'" % (self,other))
 *             return retval == true             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("SegmentChain.antisense_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyBool_FromLong((__pyx_v_retval == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1498
 *         if isinstance(other,GenomicSegment):
 *             return self.c_antisense_overlaps(SegmentChain(other))
 *         elif isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             retval = self.c_antisense_overlaps(other)
 *             if retval == bool_exception:
 */
  }

  /* "plastid/genomics/roitools.pyx":1504
 *             return retval == true
 *         else:
 *             raise TypeError("SegmentChain.antisense_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))             # <<<<<<<<<<<<<<
 * 
 *     cdef ExBool c_antisense_overlaps(self, SegmentChain other) except bool_exception:
 */
  /*else*/ {
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_antisense_overlaps_2, ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1504; __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 = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__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 = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1476
 *         return false
 * 
 *     def antisense_overlaps(self, object other):             # <<<<<<<<<<<<<<
 *         """Returns `True` if `self` and `other` share genomic positions on opposite strands
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.antisense_overlaps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1506
 *             raise TypeError("SegmentChain.antisense_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef ExBool c_antisense_overlaps(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         cdef:
 *             Strand sstrand = self.c_strand
 */

static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_antisense_overlaps(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other) {
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_sstrand;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_ostrand;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_t_2;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_antisense_overlaps", 0);

  /* "plastid/genomics/roitools.pyx":1508
 *     cdef ExBool c_antisense_overlaps(self, SegmentChain other) except bool_exception:
 *         cdef:
 *             Strand sstrand = self.c_strand             # <<<<<<<<<<<<<<
 *             Strand ostrand = other.c_strand
 *         if self.c_unstranded_overlaps(other) == true:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((enum __pyx_t_7plastid_8genomics_8c_common_Strand)__Pyx_PyInt_As_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_t_1)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_sstrand = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":1509
 *         cdef:
 *             Strand sstrand = self.c_strand
 *             Strand ostrand = other.c_strand             # <<<<<<<<<<<<<<
 *         if self.c_unstranded_overlaps(other) == true:
 *             if sstrand == unstranded or ostrand == unstranded or sstrand != ostrand:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_other), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((enum __pyx_t_7plastid_8genomics_8c_common_Strand)__Pyx_PyInt_As_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_t_1)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ostrand = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":1510
 *             Strand sstrand = self.c_strand
 *             Strand ostrand = other.c_strand
 *         if self.c_unstranded_overlaps(other) == true:             # <<<<<<<<<<<<<<
 *             if sstrand == unstranded or ostrand == unstranded or sstrand != ostrand:
 *                 return true
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_unstranded_overlaps(__pyx_v_self, __pyx_v_other); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true) != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":1511
 *             Strand ostrand = other.c_strand
 *         if self.c_unstranded_overlaps(other) == true:
 *             if sstrand == unstranded or ostrand == unstranded or sstrand != ostrand:             # <<<<<<<<<<<<<<
 *                 return true
 *         return false
 */
    __pyx_t_5 = ((__pyx_v_sstrand == __pyx_e_7plastid_8genomics_8c_common_unstranded) != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_5 = ((__pyx_v_ostrand == __pyx_e_7plastid_8genomics_8c_common_unstranded) != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_5 = ((__pyx_v_sstrand != __pyx_v_ostrand) != 0);
    __pyx_t_4 = __pyx_t_5;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_4) {

      /* "plastid/genomics/roitools.pyx":1512
 *         if self.c_unstranded_overlaps(other) == true:
 *             if sstrand == unstranded or ostrand == unstranded or sstrand != ostrand:
 *                 return true             # <<<<<<<<<<<<<<
 *         return false
 * 
 */
      __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
      goto __pyx_L0;

      /* "plastid/genomics/roitools.pyx":1511
 *             Strand ostrand = other.c_strand
 *         if self.c_unstranded_overlaps(other) == true:
 *             if sstrand == unstranded or ostrand == unstranded or sstrand != ostrand:             # <<<<<<<<<<<<<<
 *                 return true
 *         return false
 */
    }

    /* "plastid/genomics/roitools.pyx":1510
 *             Strand sstrand = self.c_strand
 *             Strand ostrand = other.c_strand
 *         if self.c_unstranded_overlaps(other) == true:             # <<<<<<<<<<<<<<
 *             if sstrand == unstranded or ostrand == unstranded or sstrand != ostrand:
 *                 return true
 */
  }

  /* "plastid/genomics/roitools.pyx":1513
 *             if sstrand == unstranded or ostrand == unstranded or sstrand != ostrand:
 *                 return true
 *         return false             # <<<<<<<<<<<<<<
 * 
 *     def covers(self, object other):
 */
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1506
 *             raise TypeError("SegmentChain.antisense_overlaps() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef ExBool c_antisense_overlaps(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         cdef:
 *             Strand sstrand = self.c_strand
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_antisense_overlaps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_bool_exception;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1515
 *         return false
 * 
 *     def covers(self, object other):             # <<<<<<<<<<<<<<
 *         """Return `True` if `self` and `other` share a chromosome and strand,
 *         and all genomic positions in `other` are present in `self`.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_41covers(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_40covers[] = "SegmentChain.covers(self, other)\nReturn `True` if `self` and `other` share a chromosome and strand,\n        and all genomic positions in `other` are present in `self`.\n        By convention, zero-length |SegmentChains| are not covered by other\n        chains.\n        \n        \n        Parameters\n        ----------\n        other : |SegmentChain| or |GenomicSegment|\n        \tQuery feature\n         \n        Returns\n        -------\n        bool\n            `True` if `self` and `other` share a chromosome and strand, and all\n            genomic positions in `other` are present in `self`. Otherwise `False`\n        \n        Raises\n        ------\n        TypeError\n            if `other` is not a |GenomicSegment| or |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_41covers(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("covers (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_40covers(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_other));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_40covers(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __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("covers", 0);

  /* "plastid/genomics/roitools.pyx":1539
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return self.c_covers(other) == true
 *         elif isinstance(other,GenomicSegment):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1540
 *         cdef ExBool retval
 *         if isinstance(other,SegmentChain):
 *             return self.c_covers(other) == true             # <<<<<<<<<<<<<<
 *         elif isinstance(other,GenomicSegment):
 *             return self.c_covers(SegmentChain(other)) == true
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_covers(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other)); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1539
 *         """
 *         cdef ExBool retval
 *         if isinstance(other,SegmentChain):             # <<<<<<<<<<<<<<
 *             return self.c_covers(other) == true
 *         elif isinstance(other,GenomicSegment):
 */
  }

  /* "plastid/genomics/roitools.pyx":1541
 *         if isinstance(other,SegmentChain):
 *             return self.c_covers(other) == true
 *         elif isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_covers(SegmentChain(other)) == true
 *         else:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":1542
 *             return self.c_covers(other) == true
 *         elif isinstance(other,GenomicSegment):
 *             return self.c_covers(SegmentChain(other)) == true             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("SegmentChain.covers() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_other);
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_covers(__pyx_v_self, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_5)); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyBool_FromLong((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1541
 *         if isinstance(other,SegmentChain):
 *             return self.c_covers(other) == true
 *         elif isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return self.c_covers(SegmentChain(other)) == true
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1544
 *             return self.c_covers(SegmentChain(other)) == true
 *         else:
 *             raise TypeError("SegmentChain.covers() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))             # <<<<<<<<<<<<<<
 * 
 *     cdef ExBool c_covers(self, SegmentChain other) except bool_exception:
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_covers_is_only_defi, ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1515
 *         return false
 * 
 *     def covers(self, object other):             # <<<<<<<<<<<<<<
 *         """Return `True` if `self` and `other` share a chromosome and strand,
 *         and all genomic positions in `other` are present in `self`.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.covers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1546
 *             raise TypeError("SegmentChain.covers() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef ExBool c_covers(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         """Return `True` if `self` and `other` share a chromosome and strand,
 *         and all genomic positions in `other` are present in `self`.
 */

static enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_covers(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_other) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_sspan = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_ospan = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_covers", 0);

  /* "plastid/genomics/roitools.pyx":1570
 *         """
 *         cdef:
 *             GenomicSegment sspan = self.spanning_segment             # <<<<<<<<<<<<<<
 *             GenomicSegment ospan = other.spanning_segment
 *         if len(self) == 0 or len(other) == 0:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_sspan = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1571
 *         cdef:
 *             GenomicSegment sspan = self.spanning_segment
 *             GenomicSegment ospan = other.spanning_segment             # <<<<<<<<<<<<<<
 *         if len(self) == 0 or len(other) == 0:
 *             return false
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_other->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ospan = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1572
 *             GenomicSegment sspan = self.spanning_segment
 *             GenomicSegment ospan = other.spanning_segment
 *         if len(self) == 0 or len(other) == 0:             # <<<<<<<<<<<<<<
 *             return false
 *         elif sspan.chrom  == ospan.chrom and\
 */
  __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = PyObject_Length(((PyObject *)__pyx_v_other)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((__pyx_t_3 == 0) != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1573
 *             GenomicSegment ospan = other.spanning_segment
 *         if len(self) == 0 or len(other) == 0:
 *             return false             # <<<<<<<<<<<<<<
 *         elif sspan.chrom  == ospan.chrom and\
 *              sspan.c_strand == ospan.c_strand and\
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1572
 *             GenomicSegment sspan = self.spanning_segment
 *             GenomicSegment ospan = other.spanning_segment
 *         if len(self) == 0 or len(other) == 0:             # <<<<<<<<<<<<<<
 *             return false
 *         elif sspan.chrom  == ospan.chrom and\
 */
  }

  /* "plastid/genomics/roitools.pyx":1574
 *         if len(self) == 0 or len(other) == 0:
 *             return false
 *         elif sspan.chrom  == ospan.chrom and\             # <<<<<<<<<<<<<<
 *              sspan.c_strand == ospan.c_strand and\
 *              other.c_get_position_set() & self.c_get_position_set() == other.c_get_position_set():
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_sspan->chrom, __pyx_v_ospan->chrom, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }

  /* "plastid/genomics/roitools.pyx":1575
 *             return false
 *         elif sspan.chrom  == ospan.chrom and\
 *              sspan.c_strand == ospan.c_strand and\             # <<<<<<<<<<<<<<
 *              other.c_get_position_set() & self.c_get_position_set() == other.c_get_position_set():
 *             return true
 */
  __pyx_t_5 = ((__pyx_v_sspan->c_strand == __pyx_v_ospan->c_strand) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }

  /* "plastid/genomics/roitools.pyx":1576
 *         elif sspan.chrom  == ospan.chrom and\
 *              sspan.c_strand == ospan.c_strand and\
 *              other.c_get_position_set() & self.c_get_position_set() == other.c_get_position_set():             # <<<<<<<<<<<<<<
 *             return true
 *         return false
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other->__pyx_vtab)->c_get_position_set(__pyx_v_other); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_position_set(__pyx_v_self); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_And(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __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_6); __pyx_t_6 = 0;
  __pyx_t_6 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_other->__pyx_vtab)->c_get_position_set(__pyx_v_other); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __pyx_t_5;
  __pyx_L6_bool_binop_done:;

  /* "plastid/genomics/roitools.pyx":1574
 *         if len(self) == 0 or len(other) == 0:
 *             return false
 *         elif sspan.chrom  == ospan.chrom and\             # <<<<<<<<<<<<<<
 *              sspan.c_strand == ospan.c_strand and\
 *              other.c_get_position_set() & self.c_get_position_set() == other.c_get_position_set():
 */
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1577
 *              sspan.c_strand == ospan.c_strand and\
 *              other.c_get_position_set() & self.c_get_position_set() == other.c_get_position_set():
 *             return true             # <<<<<<<<<<<<<<
 *         return false
 * 
 */
    __pyx_r = __pyx_e_7plastid_8genomics_8c_common_true;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1574
 *         if len(self) == 0 or len(other) == 0:
 *             return false
 *         elif sspan.chrom  == ospan.chrom and\             # <<<<<<<<<<<<<<
 *              sspan.c_strand == ospan.c_strand and\
 *              other.c_get_position_set() & self.c_get_position_set() == other.c_get_position_set():
 */
  }

  /* "plastid/genomics/roitools.pyx":1578
 *              other.c_get_position_set() & self.c_get_position_set() == other.c_get_position_set():
 *             return true
 *         return false             # <<<<<<<<<<<<<<
 * 
 *     cpdef SegmentChain get_antisense(self):
 */
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_false;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1546
 *             raise TypeError("SegmentChain.covers() is only defined for GenomicSegments and SegmentChains. Found %s." % type(other))
 * 
 *     cdef ExBool c_covers(self, SegmentChain other) except bool_exception:             # <<<<<<<<<<<<<<
 *         """Return `True` if `self` and `other` share a chromosome and strand,
 *         and all genomic positions in `other` are present in `self`.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_covers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_e_7plastid_8genomics_8c_common_bool_exception;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_sspan);
  __Pyx_XDECREF((PyObject *)__pyx_v_ospan);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1580
 *         return false
 * 
 *     cpdef SegmentChain get_antisense(self):             # <<<<<<<<<<<<<<
 *         """Returns an |SegmentChain| antisense to `self`, with empty `attr` dict.
 * 
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_43get_antisense(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_get_antisense(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_new_chain = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_span = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_strand;
  PyObject *__pyx_v_chrom = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_new_strand;
  PyObject *__pyx_v_new_segments = 0;
  PyObject *__pyx_v_s_strand = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_antisense", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_antisense); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __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_7plastid_8genomics_8roitools_12SegmentChain_43get_antisense)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__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;
  }

  /* "plastid/genomics/roitools.pyx":1589
 *         """
 *         cdef:
 *             SegmentChain new_chain = SegmentChain()             # <<<<<<<<<<<<<<
 *             GenomicSegment span = self.spanning_segment
 *             Strand strand = span.c_strand
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_new_chain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1590
 *         cdef:
 *             SegmentChain new_chain = SegmentChain()
 *             GenomicSegment span = self.spanning_segment             # <<<<<<<<<<<<<<
 *             Strand strand = span.c_strand
 *             str chrom = span.chrom
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_span = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1591
 *             SegmentChain new_chain = SegmentChain()
 *             GenomicSegment span = self.spanning_segment
 *             Strand strand = span.c_strand             # <<<<<<<<<<<<<<
 *             str chrom = span.chrom
 *             GenomicSegment seg
 */
  __pyx_t_5 = __pyx_v_span->c_strand;
  __pyx_v_strand = __pyx_t_5;

  /* "plastid/genomics/roitools.pyx":1592
 *             GenomicSegment span = self.spanning_segment
 *             Strand strand = span.c_strand
 *             str chrom = span.chrom             # <<<<<<<<<<<<<<
 *             GenomicSegment seg
 *             Strand new_strand
 */
  __pyx_t_1 = __pyx_v_span->chrom;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_chrom = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1595
 *             GenomicSegment seg
 *             Strand new_strand
 *             list new_segments = []             # <<<<<<<<<<<<<<
 *             str s_strand
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_new_segments = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1598
 *             str s_strand
 * 
 *         if strand == forward_strand:             # <<<<<<<<<<<<<<
 *             new_strand = reverse_strand
 *         elif strand == reverse_strand:
 */
  switch (__pyx_v_strand) {
    case __pyx_e_7plastid_8genomics_8c_common_forward_strand:

    /* "plastid/genomics/roitools.pyx":1599
 * 
 *         if strand == forward_strand:
 *             new_strand = reverse_strand             # <<<<<<<<<<<<<<
 *         elif strand == reverse_strand:
 *             new_strand = forward_strand
 */
    __pyx_v_new_strand = __pyx_e_7plastid_8genomics_8c_common_reverse_strand;

    /* "plastid/genomics/roitools.pyx":1598
 *             str s_strand
 * 
 *         if strand == forward_strand:             # <<<<<<<<<<<<<<
 *             new_strand = reverse_strand
 *         elif strand == reverse_strand:
 */
    break;

    /* "plastid/genomics/roitools.pyx":1600
 *         if strand == forward_strand:
 *             new_strand = reverse_strand
 *         elif strand == reverse_strand:             # <<<<<<<<<<<<<<
 *             new_strand = forward_strand
 *         elif strand == unstranded:
 */
    case __pyx_e_7plastid_8genomics_8c_common_reverse_strand:

    /* "plastid/genomics/roitools.pyx":1601
 *             new_strand = reverse_strand
 *         elif strand == reverse_strand:
 *             new_strand = forward_strand             # <<<<<<<<<<<<<<
 *         elif strand == unstranded:
 *             new_strand = unstranded
 */
    __pyx_v_new_strand = __pyx_e_7plastid_8genomics_8c_common_forward_strand;

    /* "plastid/genomics/roitools.pyx":1600
 *         if strand == forward_strand:
 *             new_strand = reverse_strand
 *         elif strand == reverse_strand:             # <<<<<<<<<<<<<<
 *             new_strand = forward_strand
 *         elif strand == unstranded:
 */
    break;

    /* "plastid/genomics/roitools.pyx":1602
 *         elif strand == reverse_strand:
 *             new_strand = forward_strand
 *         elif strand == unstranded:             # <<<<<<<<<<<<<<
 *             new_strand = unstranded
 *         else:
 */
    case __pyx_e_7plastid_8genomics_8c_common_unstranded:

    /* "plastid/genomics/roitools.pyx":1603
 *             new_strand = forward_strand
 *         elif strand == unstranded:
 *             new_strand = unstranded             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Strand for SegmentChain '%s' is undefined and has no anti-sense." % self)
 */
    __pyx_v_new_strand = __pyx_e_7plastid_8genomics_8c_common_unstranded;

    /* "plastid/genomics/roitools.pyx":1602
 *         elif strand == reverse_strand:
 *             new_strand = forward_strand
 *         elif strand == unstranded:             # <<<<<<<<<<<<<<
 *             new_strand = unstranded
 *         else:
 */
    break;
    default:

    /* "plastid/genomics/roitools.pyx":1605
 *             new_strand = unstranded
 *         else:
 *             raise ValueError("Strand for SegmentChain '%s' is undefined and has no anti-sense." % self)             # <<<<<<<<<<<<<<
 * 
 *         s_strand = strand_to_str(new_strand)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Strand_for_SegmentChain_s_is_und, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __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 = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__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 = 1605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    break;
  }

  /* "plastid/genomics/roitools.pyx":1607
 *             raise ValueError("Strand for SegmentChain '%s' is undefined and has no anti-sense." % self)
 * 
 *         s_strand = strand_to_str(new_strand)             # <<<<<<<<<<<<<<
 * 
 *         for seg in self._segments:
 */
  __pyx_t_1 = __pyx_f_7plastid_8genomics_8roitools_strand_to_str(__pyx_v_new_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_s_strand = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1609
 *         s_strand = strand_to_str(new_strand)
 * 
 *         for seg in self._segments:             # <<<<<<<<<<<<<<
 *             new_segments.append(GenomicSegment(chrom,seg.start,seg.end,s_strand))
 * 
 */
  if (unlikely(__pyx_v_self->_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __pyx_v_self->_segments; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
  for (;;) {
    if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_seg, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":1610
 * 
 *         for seg in self._segments:
 *             new_segments.append(GenomicSegment(chrom,seg.start,seg.end,s_strand))             # <<<<<<<<<<<<<<
 * 
 *         new_chain._set_segments(new_segments)
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_seg->start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_seg->end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_s_strand);
    __Pyx_GIVEREF(__pyx_v_s_strand);
    PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_s_strand);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_new_segments, __pyx_t_3); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":1609
 *         s_strand = strand_to_str(new_strand)
 * 
 *         for seg in self._segments:             # <<<<<<<<<<<<<<
 *             new_segments.append(GenomicSegment(chrom,seg.start,seg.end,s_strand))
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1612
 *             new_segments.append(GenomicSegment(chrom,seg.start,seg.end,s_strand))
 * 
 *         new_chain._set_segments(new_segments)             # <<<<<<<<<<<<<<
 * 
 *         return new_chain
 */
  __pyx_t_8 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_new_chain->__pyx_vtab)->_set_segments(__pyx_v_new_chain, __pyx_v_new_segments); if (unlikely(__pyx_t_8 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":1614
 *         new_chain._set_segments(new_segments)
 * 
 *         return new_chain             # <<<<<<<<<<<<<<
 * 
 *     cdef list c_get_position_list(self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_new_chain));
  __pyx_r = __pyx_v_new_chain;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1580
 *         return false
 * 
 *     cpdef SegmentChain get_antisense(self):             # <<<<<<<<<<<<<<
 *         """Returns an |SegmentChain| antisense to `self`, with empty `attr` dict.
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.get_antisense", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_new_chain);
  __Pyx_XDECREF((PyObject *)__pyx_v_span);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF((PyObject *)__pyx_v_seg);
  __Pyx_XDECREF(__pyx_v_new_segments);
  __Pyx_XDECREF(__pyx_v_s_strand);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_43get_antisense(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_42get_antisense[] = "SegmentChain.get_antisense(self) -> SegmentChain\nReturns an |SegmentChain| antisense to `self`, with empty `attr` dict.\n        \n        Returns\n        -------\n        SegmentChain\n            |SegmentChain| antisense to `self`\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_43get_antisense(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_antisense (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_42get_antisense(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_42get_antisense(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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_antisense", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_get_antisense(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_antisense", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1616
 *         return new_chain
 * 
 *     cdef list c_get_position_list(self):             # <<<<<<<<<<<<<<
 *         """Retrieve a sorted **end-inclusive** numpy array of genomic coordinates in this |SegmentChain|
 * 
 */

static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_list(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("c_get_position_list", 0);

  /* "plastid/genomics/roitools.pyx":1624
 *             Genomic coordinates in `self`, as integers, in genomic order
 *         """
 *         return self._position_hash.tolist()             # <<<<<<<<<<<<<<
 * 
 *     def get_position_list(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_position_hash), __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1616
 *         return new_chain
 * 
 *     cdef list c_get_position_list(self):             # <<<<<<<<<<<<<<
 *         """Retrieve a sorted **end-inclusive** numpy array of genomic coordinates in this |SegmentChain|
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_get_position_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1626
 *         return self._position_hash.tolist()
 * 
 *     def get_position_list(self):             # <<<<<<<<<<<<<<
 *         """Retrieve a sorted **end-inclusive** numpy array of genomic coordinates in this |SegmentChain|
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_45get_position_list(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_44get_position_list[] = "SegmentChain.get_position_list(self)\nRetrieve a sorted **end-inclusive** numpy array of genomic coordinates in this |SegmentChain|\n         \n\n        Returns\n        -------\n        list\n            Genomic coordinates in `self`, as integers, in genomic order\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_45get_position_list(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_position_list (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_44get_position_list(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_44get_position_list(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("get_position_list", 0);

  /* "plastid/genomics/roitools.pyx":1635
 *             Genomic coordinates in `self`, as integers, in genomic order
 *         """
 *         return self._position_hash.tolist()             # <<<<<<<<<<<<<<
 * 
 *     cdef numpy.ndarray c_get_position_array(self, bint copy):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_position_hash), __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1626
 *         return self._position_hash.tolist()
 * 
 *     def get_position_list(self):             # <<<<<<<<<<<<<<
 *         """Retrieve a sorted **end-inclusive** numpy array of genomic coordinates in this |SegmentChain|
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_position_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1637
 *         return self._position_hash.tolist()
 * 
 *     cdef numpy.ndarray c_get_position_array(self, bint copy):             # <<<<<<<<<<<<<<
 *         """Retrieve a sorted end-inclusive list of genomic coordinates in this |SegmentChain|
 * 
 */

static PyArrayObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_array(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, int __pyx_v_copy) {
  PyArrayObject *__pyx_v_positions = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_positions;
  __Pyx_Buffer __pyx_pybuffer_positions;
  PyArrayObject *__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;
  PyArrayObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_get_position_array", 0);
  __pyx_pybuffer_positions.pybuffer.buf = NULL;
  __pyx_pybuffer_positions.refcount = 0;
  __pyx_pybuffernd_positions.data = NULL;
  __pyx_pybuffernd_positions.rcbuffer = &__pyx_pybuffer_positions;

  /* "plastid/genomics/roitools.pyx":1651
 *             Ggenomic coordinates in `self`, as integers, in genomic order
 *         """
 *         cdef numpy.ndarray[LONG_t,ndim=1] positions = numpy.asarray(self._position_hash,dtype=long)             # <<<<<<<<<<<<<<
 *         if copy == False:
 *             return positions
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __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 = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_position_hash));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_position_hash));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->_position_hash));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, ((PyObject *)(&PyLong_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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 = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_positions.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_LONG_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_positions = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_positions.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_positions.diminfo[0].strides = __pyx_pybuffernd_positions.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_positions.diminfo[0].shape = __pyx_pybuffernd_positions.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_positions = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":1652
 *         """
 *         cdef numpy.ndarray[LONG_t,ndim=1] positions = numpy.asarray(self._position_hash,dtype=long)
 *         if copy == False:             # <<<<<<<<<<<<<<
 *             return positions
 *         else:
 */
  __pyx_t_6 = ((__pyx_v_copy == 0) != 0);
  if (__pyx_t_6) {

    /* "plastid/genomics/roitools.pyx":1653
 *         cdef numpy.ndarray[LONG_t,ndim=1] positions = numpy.asarray(self._position_hash,dtype=long)
 *         if copy == False:
 *             return positions             # <<<<<<<<<<<<<<
 *         else:
 *             return copy.deepcopy(positions)
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_positions));
    __pyx_r = ((PyArrayObject *)__pyx_v_positions);
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1652
 *         """
 *         cdef numpy.ndarray[LONG_t,ndim=1] positions = numpy.asarray(self._position_hash,dtype=long)
 *         if copy == False:             # <<<<<<<<<<<<<<
 *             return positions
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1655
 *             return positions
 *         else:
 *             return copy.deepcopy(positions)             # <<<<<<<<<<<<<<
 * 
 *     def get_position_set(self):
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_copy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_positions)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_positions));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_positions));
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, ((PyObject *)__pyx_v_positions));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":1637
 *         return self._position_hash.tolist()
 * 
 *     cdef numpy.ndarray c_get_position_array(self, bint copy):             # <<<<<<<<<<<<<<
 *         """Retrieve a sorted end-inclusive list of genomic coordinates in this |SegmentChain|
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __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_positions.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_get_position_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_positions.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_positions);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1657
 *             return copy.deepcopy(positions)
 * 
 *     def get_position_set(self):             # <<<<<<<<<<<<<<
 *         """Retrieve an end-inclusive set of genomic coordinates included in this |SegmentChain|
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_47get_position_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_46get_position_set[] = "SegmentChain.get_position_set(self)\nRetrieve an end-inclusive set of genomic coordinates included in this |SegmentChain|\n        \n        Returns\n        -------\n        set\n            Set of genomic coordinates, as integers\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_47get_position_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_position_set (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_46get_position_set(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_46get_position_set(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("get_position_set", 0);

  /* "plastid/genomics/roitools.pyx":1665
 *             Set of genomic coordinates, as integers
 *         """
 *         return set(self.c_get_position_list())             # <<<<<<<<<<<<<<
 * 
 *     cdef set c_get_position_set(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_position_list(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __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;

  /* "plastid/genomics/roitools.pyx":1657
 *             return copy.deepcopy(positions)
 * 
 *     def get_position_set(self):             # <<<<<<<<<<<<<<
 *         """Retrieve an end-inclusive set of genomic coordinates included in this |SegmentChain|
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_position_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1667
 *         return set(self.c_get_position_list())
 * 
 *     cdef set c_get_position_set(self):             # <<<<<<<<<<<<<<
 *         return set(self._position_hash.tolist())
 * 
 */

static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_set(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("c_get_position_set", 0);

  /* "plastid/genomics/roitools.pyx":1668
 * 
 *     cdef set c_get_position_set(self):
 *         return set(self._position_hash.tolist())             # <<<<<<<<<<<<<<
 * 
 *     cpdef set get_masked_position_set(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_position_hash), __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1667
 *         return set(self.c_get_position_list())
 * 
 *     cdef set c_get_position_set(self):             # <<<<<<<<<<<<<<
 *         return set(self._position_hash.tolist())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_get_position_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1670
 *         return set(self._position_hash.tolist())
 * 
 *     cpdef set get_masked_position_set(self):             # <<<<<<<<<<<<<<
 *         """Returns a set of genomic coordinates corresponding to positions in
 *         `self` that **HAVE NOT** been masked using :meth:`SegmentChain.add_masks`
 */

static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_49get_masked_position_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_get_masked_position_set(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, int __pyx_skip_dispatch) {
  PyArrayObject *__pyx_v_mask = 0;
  PyArrayObject *__pyx_v_positions = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_mask;
  __Pyx_Buffer __pyx_pybuffer_mask;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_positions;
  __Pyx_Buffer __pyx_pybuffer_positions;
  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;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyArrayObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_masked_position_set", 0);
  __pyx_pybuffer_mask.pybuffer.buf = NULL;
  __pyx_pybuffer_mask.refcount = 0;
  __pyx_pybuffernd_mask.data = NULL;
  __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask;
  __pyx_pybuffer_positions.pybuffer.buf = NULL;
  __pyx_pybuffer_positions.refcount = 0;
  __pyx_pybuffernd_positions.data = NULL;
  __pyx_pybuffernd_positions.rcbuffer = &__pyx_pybuffer_positions;
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_masked_position_set); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1670; __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_7plastid_8genomics_8roitools_12SegmentChain_49get_masked_position_set)) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(PySet_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "set", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyObject*)__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;
  }

  /* "plastid/genomics/roitools.pyx":1683
 *             numpy.ndarray[LONG_t,ndim=1] positions #= numpy.frombuffer(self._position_hash,dtype=LONG)
 * 
 *         if len(self._position_mask) == 0:             # <<<<<<<<<<<<<<
 *             return self.c_get_position_set()
 *         else:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->_position_mask);
  __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 = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = Py_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = ((__pyx_t_5 == 0) != 0);
  if (__pyx_t_6) {

    /* "plastid/genomics/roitools.pyx":1684
 * 
 *         if len(self._position_mask) == 0:
 *             return self.c_get_position_set()             # <<<<<<<<<<<<<<
 *         else:
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_position_set(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":1683
 *             numpy.ndarray[LONG_t,ndim=1] positions #= numpy.frombuffer(self._position_hash,dtype=LONG)
 * 
 *         if len(self._position_mask) == 0:             # <<<<<<<<<<<<<<
 *             return self.c_get_position_set()
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":1686
 *             return self.c_get_position_set()
 *         else:
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)             # <<<<<<<<<<<<<<
 *             positions = numpy.frombuffer(self._position_hash,dtype=LONG)
 *             return set(positions[mask == 0])
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __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 = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->_position_mask));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_position_mask));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->_position_mask));
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_intc); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = ((PyArrayObject *)__pyx_t_7);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
      __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_9 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
        }
      }
      __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_8 = 0;
    __pyx_v_mask = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "plastid/genomics/roitools.pyx":1687
 *         else:
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 *             positions = numpy.frombuffer(self._position_hash,dtype=LONG)             # <<<<<<<<<<<<<<
 *             return set(positions[mask == 0])
 * 
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __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 = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->_position_hash));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_position_hash));
    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_self->_position_hash));
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_LONG); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __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_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_13 = ((PyArrayObject *)__pyx_t_2);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_positions.rcbuffer->pybuffer);
      __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_positions.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_LONG_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_9 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_positions.rcbuffer->pybuffer, (PyObject*)__pyx_v_positions, &__Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_LONG_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_positions.diminfo[0].strides = __pyx_pybuffernd_positions.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_positions.diminfo[0].shape = __pyx_pybuffernd_positions.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_13 = 0;
    __pyx_v_positions = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":1688
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 *             positions = numpy.frombuffer(self._position_hash,dtype=LONG)
 *             return set(positions[mask == 0])             # <<<<<<<<<<<<<<
 * 
 *     def get_name(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_mask), __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_positions), __pyx_t_2); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PySet_New(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":1670
 *         return set(self._position_hash.tolist())
 * 
 *     cpdef set get_masked_position_set(self):             # <<<<<<<<<<<<<<
 *         """Returns a set of genomic coordinates corresponding to positions in
 *         `self` that **HAVE NOT** been masked using :meth:`SegmentChain.add_masks`
 */

  /* function exit code */
  __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);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_positions.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_masked_position_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_positions.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_mask);
  __Pyx_XDECREF((PyObject *)__pyx_v_positions);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_49get_masked_position_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_48get_masked_position_set[] = "SegmentChain.get_masked_position_set(self) -> set\nReturns a set of genomic coordinates corresponding to positions in \n        `self` that **HAVE NOT** been masked using :meth:`SegmentChain.add_masks`\n\n        Returns\n        -------\n        set\n            Set of genomic coordinates, as integers\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_49get_masked_position_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_masked_position_set (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_48get_masked_position_set(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_48get_masked_position_set(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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_masked_position_set", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_get_masked_position_set(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_masked_position_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1690
 *             return set(positions[mask == 0])
 * 
 *     def get_name(self):             # <<<<<<<<<<<<<<
 *         """Returns the name of this |SegmentChain|, first searching through
 *         `self.attr` for the keys `ID`, `Name`, and `name`. If no value is found
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_51get_name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_50get_name[] = "SegmentChain.get_name(self)\nReturns the name of this |SegmentChain|, first searching through\n        `self.attr` for the keys `ID`, `Name`, and `name`. If no value is found\n        for any of those keys, a name is generated using :meth:`SegmentChain.__str__`\n        \n        Returns\n        -------\n        str\n            In order of preference, `ID` from `self.attr`, `Name` from\n            `self.attr`, `name` from `self.attr` or ``str(self)`` \n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_51get_name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_name (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_50get_name(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_50get_name(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_v_name = NULL;
  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("get_name", 0);

  /* "plastid/genomics/roitools.pyx":1701
 *             `self.attr`, `name` from `self.attr` or ``str(self)``
 *         """
 *         name = self.attr.get("ID",             # <<<<<<<<<<<<<<
 *                self.attr.get("Name",
 *                self.attr.get("name",
 */
  if (unlikely(__pyx_v_self->attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1702
 *         """
 *         name = self.attr.get("ID",
 *                self.attr.get("Name",             # <<<<<<<<<<<<<<
 *                self.attr.get("name",
 *                              str(self))))
 */
  if (unlikely(__pyx_v_self->attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1703
 *         name = self.attr.get("ID",
 *                self.attr.get("Name",
 *                self.attr.get("name",             # <<<<<<<<<<<<<<
 *                              str(self))))
 *         return name
 */
  if (unlikely(__pyx_v_self->attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1704
 *                self.attr.get("Name",
 *                self.attr.get("name",
 *                              str(self))))             # <<<<<<<<<<<<<<
 *         return name
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1703
 *         name = self.attr.get("ID",
 *                self.attr.get("Name",
 *                self.attr.get("name",             # <<<<<<<<<<<<<<
 *                              str(self))))
 *         return name
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_name_2, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1702
 *         """
 *         name = self.attr.get("ID",
 *                self.attr.get("Name",             # <<<<<<<<<<<<<<
 *                self.attr.get("name",
 *                              str(self))))
 */
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_Name, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1701
 *             `self.attr`, `name` from `self.attr` or ``str(self)``
 *         """
 *         name = self.attr.get("ID",             # <<<<<<<<<<<<<<
 *                self.attr.get("Name",
 *                self.attr.get("name",
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_ID, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1705
 *                self.attr.get("name",
 *                              str(self))))
 *         return name             # <<<<<<<<<<<<<<
 * 
 *     def get_gene(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_name);
  __pyx_r = __pyx_v_name;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1690
 *             return set(positions[mask == 0])
 * 
 *     def get_name(self):             # <<<<<<<<<<<<<<
 *         """Returns the name of this |SegmentChain|, first searching through
 *         `self.attr` for the keys `ID`, `Name`, and `name`. If no value is found
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1707
 *         return name
 * 
 *     def get_gene(self):             # <<<<<<<<<<<<<<
 *         """Return name of gene associated with |SegmentChain|, if any,
 *         by searching through `self.attr` for the keys `gene_id` and `Parent`.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_53get_gene(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_52get_gene[] = "SegmentChain.get_gene(self)\nReturn name of gene associated with |SegmentChain|, if any, \n        by searching through `self.attr` for the keys `gene_id` and `Parent`.\n        If one is not found, a generated gene name for the SegmentChain is \n        made from :py:meth:`get_name`.\n\n        Returns\n        -------\n        str\n            Returns in order of preference, `gene_id` from `self.attr`, \n            `Parent` from `self.attr` or ``'gene_%s' % self.get_name()``\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_53get_gene(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_gene (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_52get_gene(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_52get_gene(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_v_gene = 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_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_gene", 0);

  /* "plastid/genomics/roitools.pyx":1719
 *             `Parent` from `self.attr` or ``'gene_%s' % self.get_name()``
 *         """
 *         gene = self.attr.get("gene_id",             # <<<<<<<<<<<<<<
 *                self.attr.get("Parent",
 *                "gene_%s" % self.get_name()))
 */
  if (unlikely(__pyx_v_self->attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1720
 *         """
 *         gene = self.attr.get("gene_id",
 *                self.attr.get("Parent",             # <<<<<<<<<<<<<<
 *                "gene_%s" % self.get_name()))
 *         if isinstance(gene,list):
 */
  if (unlikely(__pyx_v_self->attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":1721
 *         gene = self.attr.get("gene_id",
 *                self.attr.get("Parent",
 *                "gene_%s" % self.get_name()))             # <<<<<<<<<<<<<<
 *         if isinstance(gene,list):
 *             gene = ",".join(sorted(gene))
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_gene__s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1720
 *         """
 *         gene = self.attr.get("gene_id",
 *                self.attr.get("Parent",             # <<<<<<<<<<<<<<
 *                "gene_%s" % self.get_name()))
 *         if isinstance(gene,list):
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_Parent, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1719
 *             `Parent` from `self.attr` or ``'gene_%s' % self.get_name()``
 *         """
 *         gene = self.attr.get("gene_id",             # <<<<<<<<<<<<<<
 *                self.attr.get("Parent",
 *                "gene_%s" % self.get_name()))
 */
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_gene_id, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_gene = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1722
 *                self.attr.get("Parent",
 *                "gene_%s" % self.get_name()))
 *         if isinstance(gene,list):             # <<<<<<<<<<<<<<
 *             gene = ",".join(sorted(gene))
 * 
 */
  __pyx_t_4 = PyList_Check(__pyx_v_gene); 
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "plastid/genomics/roitools.pyx":1723
 *                "gene_%s" % self.get_name()))
 *         if isinstance(gene,list):
 *             gene = ",".join(sorted(gene))             # <<<<<<<<<<<<<<
 * 
 *         return gene
 */
    __pyx_t_1 = PySequence_List(__pyx_v_gene); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_6 = PyList_Sort(__pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_gene, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1722
 *                self.attr.get("Parent",
 *                "gene_%s" % self.get_name()))
 *         if isinstance(gene,list):             # <<<<<<<<<<<<<<
 *             gene = ",".join(sorted(gene))
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":1725
 *             gene = ",".join(sorted(gene))
 * 
 *         return gene             # <<<<<<<<<<<<<<
 * 
 *     def get_length(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_gene);
  __pyx_r = __pyx_v_gene;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1707
 *         return name
 * 
 *     def get_gene(self):             # <<<<<<<<<<<<<<
 *         """Return name of gene associated with |SegmentChain|, if any,
 *         by searching through `self.attr` for the keys `gene_id` and `Parent`.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_gene", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gene);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1727
 *         return gene
 * 
 *     def get_length(self):             # <<<<<<<<<<<<<<
 *         """Return total length, in nucleotides, of `self`
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_55get_length(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_54get_length[] = "SegmentChain.get_length(self)\nReturn total length, in nucleotides, of `self`\n        \n        Returns\n        -------\n        int\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_55get_length(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_length (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_54get_length(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_54get_length(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_v_name = 0;
  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 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_length", 0);

  /* "plastid/genomics/roitools.pyx":1734
 *         int
 *         """
 *         cdef str name = self.__class__.__name__             # <<<<<<<<<<<<<<
 *         warnings.warn("%s.get_length() is deprecated and will be removed in future versions. Use %s.length property instead" % (name,name),
 *                 DeprecationWarning)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_name = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1735
 *         """
 *         cdef str name = self.__class__.__name__
 *         warnings.warn("%s.get_length() is deprecated and will be removed in future versions. Use %s.length property instead" % (name,name),             # <<<<<<<<<<<<<<
 *                 DeprecationWarning)
 *         return self.length
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __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(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_name);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_name);
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_get_length_is_deprecated_and, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1736
 *         cdef str name = self.__class__.__name__
 *         warnings.warn("%s.get_length() is deprecated and will be removed in future versions. Use %s.length property instead" % (name,name),
 *                 DeprecationWarning)             # <<<<<<<<<<<<<<
 *         return self.length
 * 
 */
  __pyx_t_1 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_1) {
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_4);
  __Pyx_INCREF(__pyx_builtin_DeprecationWarning);
  __Pyx_GIVEREF(__pyx_builtin_DeprecationWarning);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_builtin_DeprecationWarning);
  __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1737
 *         warnings.warn("%s.get_length() is deprecated and will be removed in future versions. Use %s.length property instead" % (name,name),
 *                 DeprecationWarning)
 *         return self.length             # <<<<<<<<<<<<<<
 * 
 *     def get_masked_length(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1727
 *         return gene
 * 
 *     def get_length(self):             # <<<<<<<<<<<<<<
 *         """Return total length, in nucleotides, of `self`
 * 
 */

  /* function exit code */
  __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_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_length", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1739
 *         return self.length
 * 
 *     def get_masked_length(self):             # <<<<<<<<<<<<<<
 *         """Return the total length, in nucleotides, of positions in `self`
 *         that have not been masked using :meth:`SegmentChain.add_masks`
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_57get_masked_length(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_56get_masked_length[] = "SegmentChain.get_masked_length(self)\nReturn the total length, in nucleotides, of positions in `self`\n        that have not been masked using :meth:`SegmentChain.add_masks`\n        \n        Returns\n        -------\n        int\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_57get_masked_length(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_masked_length (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_56get_masked_length(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_56get_masked_length(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_v_name = 0;
  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 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_masked_length", 0);

  /* "plastid/genomics/roitools.pyx":1747
 *         int
 *         """
 *         cdef str name = self.__class__.__name__             # <<<<<<<<<<<<<<
 *         warnings.warn("%s.get_masked_length() is deprecated and will be removed in future versions. Use %s.masked_length property instead" % (name,name),
 *                 DeprecationWarning)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_name = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1748
 *         """
 *         cdef str name = self.__class__.__name__
 *         warnings.warn("%s.get_masked_length() is deprecated and will be removed in future versions. Use %s.masked_length property instead" % (name,name),             # <<<<<<<<<<<<<<
 *                 DeprecationWarning)
 *         return self.masked_length
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __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(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_name);
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_name);
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_get_masked_length_is_deprecat, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1749
 *         cdef str name = self.__class__.__name__
 *         warnings.warn("%s.get_masked_length() is deprecated and will be removed in future versions. Use %s.masked_length property instead" % (name,name),
 *                 DeprecationWarning)             # <<<<<<<<<<<<<<
 *         return self.masked_length
 * 
 */
  __pyx_t_1 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_1) {
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_4);
  __Pyx_INCREF(__pyx_builtin_DeprecationWarning);
  __Pyx_GIVEREF(__pyx_builtin_DeprecationWarning);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_builtin_DeprecationWarning);
  __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1750
 *         warnings.warn("%s.get_masked_length() is deprecated and will be removed in future versions. Use %s.masked_length property instead" % (name,name),
 *                 DeprecationWarning)
 *         return self.masked_length             # <<<<<<<<<<<<<<
 * 
 *     cdef bint c_add_segments(self, tuple segments) except False:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->masked_length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1739
 *         return self.length
 * 
 *     def get_masked_length(self):             # <<<<<<<<<<<<<<
 *         """Return the total length, in nucleotides, of positions in `self`
 *         that have not been masked using :meth:`SegmentChain.add_masks`
 */

  /* function exit code */
  __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_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_masked_length", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1752
 *         return self.masked_length
 * 
 *     cdef bint c_add_segments(self, tuple segments) except False:             # <<<<<<<<<<<<<<
 *         """Add |GenomicSegments| to `self`. If there are
 *         already segments in the chain, the incoming segments must be
 */

static int __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_add_segments(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments) {
  PyObject *__pyx_v_my_chrom = 0;
  PyObject *__pyx_v_my_strand = 0;
  PyObject *__pyx_v_positions = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg = 0;
  int __pyx_v_length;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  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("c_add_segments", 0);

  /* "plastid/genomics/roitools.pyx":1764
 *         cdef:
 *             str my_chrom, my_strand
 *             list positions = self.c_get_position_list()             # <<<<<<<<<<<<<<
 *             GenomicSegment seg
 *             int length = len(segments)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_position_list(__pyx_v_self); 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_v_positions = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1766
 *             list positions = self.c_get_position_list()
 *             GenomicSegment seg
 *             int length = len(segments)             # <<<<<<<<<<<<<<
 * 
 *         if length > 0:
 */
  if (unlikely(__pyx_v_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_segments); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_length = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":1768
 *             int length = len(segments)
 * 
 *         if length > 0:             # <<<<<<<<<<<<<<
 *             check_segments(self,segments)
 *             seg = segments[0]
 */
  __pyx_t_3 = ((__pyx_v_length > 0) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":1769
 * 
 *         if length > 0:
 *             check_segments(self,segments)             # <<<<<<<<<<<<<<
 *             seg = segments[0]
 *             my_chrom  = seg.chrom
 */
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_check_segments(__pyx_v_self, __pyx_v_segments); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":1770
 *         if length > 0:
 *             check_segments(self,segments)
 *             seg = segments[0]             # <<<<<<<<<<<<<<
 *             my_chrom  = seg.chrom
 *             my_strand = seg.strand
 */
    if (unlikely(__pyx_v_segments == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_segments, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_seg = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1771
 *             check_segments(self,segments)
 *             seg = segments[0]
 *             my_chrom  = seg.chrom             # <<<<<<<<<<<<<<
 *             my_strand = seg.strand
 * 
 */
    __pyx_t_1 = __pyx_v_seg->chrom;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v_my_chrom = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1772
 *             seg = segments[0]
 *             my_chrom  = seg.chrom
 *             my_strand = seg.strand             # <<<<<<<<<<<<<<
 * 
 *             # add new positions
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_seg), __pyx_n_s_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_my_strand = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1775
 * 
 *             # add new positions
 *             for seg in segments:             # <<<<<<<<<<<<<<
 *                 positions.extend(range(seg.start,seg.end))
 * 
 */
    if (unlikely(__pyx_v_segments == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __pyx_v_segments; __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_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF_SET(__pyx_v_seg, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "plastid/genomics/roitools.pyx":1776
 *             # add new positions
 *             for seg in segments:
 *                 positions.extend(range(seg.start,seg.end))             # <<<<<<<<<<<<<<
 * 
 *             # reset variables
 */
      if (unlikely(__pyx_v_positions == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "extend");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_seg->start); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_seg->end); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = __Pyx_PyList_Extend(__pyx_v_positions, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "plastid/genomics/roitools.pyx":1775
 * 
 *             # add new positions
 *             for seg in segments:             # <<<<<<<<<<<<<<
 *                 positions.extend(range(seg.start,seg.end))
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1779
 * 
 *             # reset variables
 *             self._set_segments(positionlist_to_segments(my_chrom,my_strand,sorted(set(positions))))             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
    __pyx_t_5 = PySet_New(__pyx_v_positions); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PySequence_List(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_7 = PyList_Sort(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = __pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments(__pyx_v_my_chrom, __pyx_v_my_strand, ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->_set_segments(__pyx_v_self, ((PyObject*)__pyx_t_6)); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":1768
 *             int length = len(segments)
 * 
 *         if length > 0:             # <<<<<<<<<<<<<<
 *             check_segments(self,segments)
 *             seg = segments[0]
 */
  }

  /* "plastid/genomics/roitools.pyx":1781
 *             self._set_segments(positionlist_to_segments(my_chrom,my_strand,sorted(set(positions))))
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def add_segments(self,*segments):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1752
 *         return self.masked_length
 * 
 *     cdef bint c_add_segments(self, tuple segments) except False:             # <<<<<<<<<<<<<<
 *         """Add |GenomicSegments| to `self`. If there are
 *         already segments in the chain, the incoming segments must be
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_add_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_my_chrom);
  __Pyx_XDECREF(__pyx_v_my_strand);
  __Pyx_XDECREF(__pyx_v_positions);
  __Pyx_XDECREF((PyObject *)__pyx_v_seg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1783
 *         return True
 * 
 *     def add_segments(self,*segments):             # <<<<<<<<<<<<<<
 *         """Add 1 or more |GenomicSegments| to the |SegmentChain|. If there are
 *         already segments in the chain, the incoming segments must be
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_59add_segments(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_58add_segments[] = "SegmentChain.add_segments(self, *segments)\nAdd 1 or more |GenomicSegments| to the |SegmentChain|. If there are\n        already segments in the chain, the incoming segments must be \n        on the same strand and chromosome as all others present.\n\n        Parameters\n        ----------\n        segments : |GenomicSegment|\n            One or more |GenomicSegment| to add to |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_59add_segments(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_segments (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "add_segments", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_segments = __pyx_args;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_58add_segments(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_segments);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_segments);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_58add_segments(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  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("add_segments", 0);

  /* "plastid/genomics/roitools.pyx":1796
 *             int retval
 *             str msg
 *         if len(segments) > 0:             # <<<<<<<<<<<<<<
 *             if len(self._mask_segments) > 0:
 *                 warnings.warn("Segmentchain: adding segments to %s will reset its masks!",UserWarning)
 */
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_segments); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 > 0) != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":1797
 *             str msg
 *         if len(segments) > 0:
 *             if len(self._mask_segments) > 0:             # <<<<<<<<<<<<<<
 *                 warnings.warn("Segmentchain: adding segments to %s will reset its masks!",UserWarning)
 * 
 */
    __pyx_t_3 = __pyx_v_self->_mask_segments;
    __Pyx_INCREF(__pyx_t_3);
    if (unlikely(__pyx_t_3 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = PyList_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = ((__pyx_t_1 > 0) != 0);
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":1798
 *         if len(segments) > 0:
 *             if len(self._mask_segments) > 0:
 *                 warnings.warn("Segmentchain: adding segments to %s will reset its masks!",UserWarning)             # <<<<<<<<<<<<<<
 * 
 *             self.c_add_segments(segments)
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      __pyx_t_1 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_1 = 1;
        }
      }
      __pyx_t_6 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_s_Segmentchain_adding_segments_to);
      __Pyx_GIVEREF(__pyx_kp_s_Segmentchain_adding_segments_to);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_1, __pyx_kp_s_Segmentchain_adding_segments_to);
      __Pyx_INCREF(__pyx_builtin_UserWarning);
      __Pyx_GIVEREF(__pyx_builtin_UserWarning);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_1, __pyx_builtin_UserWarning);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "plastid/genomics/roitools.pyx":1797
 *             str msg
 *         if len(segments) > 0:
 *             if len(self._mask_segments) > 0:             # <<<<<<<<<<<<<<
 *                 warnings.warn("Segmentchain: adding segments to %s will reset its masks!",UserWarning)
 * 
 */
    }

    /* "plastid/genomics/roitools.pyx":1800
 *                 warnings.warn("Segmentchain: adding segments to %s will reset its masks!",UserWarning)
 * 
 *             self.c_add_segments(segments)             # <<<<<<<<<<<<<<
 * 
 *     # TODO: optimize
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_add_segments(__pyx_v_self, __pyx_v_segments); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":1796
 *             int retval
 *             str msg
 *         if len(segments) > 0:             # <<<<<<<<<<<<<<
 *             if len(self._mask_segments) > 0:
 *                 warnings.warn("Segmentchain: adding segments to %s will reset its masks!",UserWarning)
 */
  }

  /* "plastid/genomics/roitools.pyx":1783
 *         return True
 * 
 *     def add_segments(self,*segments):             # <<<<<<<<<<<<<<
 *         """Add 1 or more |GenomicSegments| to the |SegmentChain|. If there are
 *         already segments in the chain, the incoming segments must be
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.add_segments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1803
 * 
 *     # TODO: optimize
 *     def add_masks(self,*mask_segments):             # <<<<<<<<<<<<<<
 *         """Adds one or more |GenomicSegment| to the collection of masks.
 *         Masks will be trimmed to the positions of the |SegmentChain|
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_61add_masks(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_60add_masks[] = "SegmentChain.add_masks(self, *mask_segments)\nAdds one or more |GenomicSegment| to the collection of masks.\n        Masks will be trimmed to the positions of the |SegmentChain|\n        during addition.\n\n        Parameters\n        ----------\n        mask_segments : |GenomicSegment|\n            One or more segments, in genomic coordinates, covering positions to\n            exclude from return values of :meth:`get_masked_position_set`,\n            :meth:`get_masked_counts`, or :meth:`get_masked_length`\n\t\t\n        See also\n        --------\n        SegmentChain.get_masks\n        SegmentChain.get_masks_as_segmentchain\n        SegmentChain.reset_masks\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_61add_masks(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mask_segments = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_masks (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "add_masks", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_mask_segments = __pyx_args;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_60add_masks(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_mask_segments);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_mask_segments);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_60add_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_mask_segments) {
  PyObject *__pyx_v_my_chrom = 0;
  PyObject *__pyx_v_my_strand = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_segment = 0;
  PyObject *__pyx_v_positions = 0;
  PyObject *__pyx_v_new_segments = 0;
  PyObject *__pyx_v_seg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  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("add_masks", 0);

  /* "plastid/genomics/roitools.pyx":1824
 *             str my_chrom, my_strand
 *             GenomicSegment segment
 *             set positions = set()             # <<<<<<<<<<<<<<
 *             list new_segments
 * 
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_positions = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1827
 *             list new_segments
 * 
 *         if len(mask_segments) > 0:             # <<<<<<<<<<<<<<
 *             check_segments(self,mask_segments)
 *             seg  = mask_segments[0]
 */
  __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v_mask_segments); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((__pyx_t_2 > 0) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":1828
 * 
 *         if len(mask_segments) > 0:
 *             check_segments(self,mask_segments)             # <<<<<<<<<<<<<<
 *             seg  = mask_segments[0]
 *             my_chrom  = seg.chrom
 */
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_check_segments(__pyx_v_self, __pyx_v_mask_segments); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":1829
 *         if len(mask_segments) > 0:
 *             check_segments(self,mask_segments)
 *             seg  = mask_segments[0]             # <<<<<<<<<<<<<<
 *             my_chrom  = seg.chrom
 *             my_strand = seg.strand
 */
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_mask_segments, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1829; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_seg = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1830
 *             check_segments(self,mask_segments)
 *             seg  = mask_segments[0]
 *             my_chrom  = seg.chrom             # <<<<<<<<<<<<<<
 *             my_strand = seg.strand
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_seg, __pyx_n_s_chrom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_my_chrom = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1831
 *             seg  = mask_segments[0]
 *             my_chrom  = seg.chrom
 *             my_strand = seg.strand             # <<<<<<<<<<<<<<
 * 
 *             # add new positions to any existing masks
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_seg, __pyx_n_s_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_my_strand = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1834
 * 
 *             # add new positions to any existing masks
 *             for segment in list(mask_segments) + self._mask_segments:             # <<<<<<<<<<<<<<
 *                 positions |= set(range(segment.start,segment.end))
 * 
 */
    __pyx_t_1 = PySequence_List(__pyx_v_mask_segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_v_self->_mask_segments); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __pyx_t_4; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF_SET(__pyx_v_segment, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_4));
      __pyx_t_4 = 0;

      /* "plastid/genomics/roitools.pyx":1835
 *             # add new positions to any existing masks
 *             for segment in list(mask_segments) + self._mask_segments:
 *                 positions |= set(range(segment.start,segment.end))             # <<<<<<<<<<<<<<
 * 
 *             # trim away non-overlapping masks
 */
      __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_segment->start); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_segment->end); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PySet_New(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_InPlaceOr(__pyx_v_positions, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF_SET(__pyx_v_positions, ((PyObject*)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "plastid/genomics/roitools.pyx":1834
 * 
 *             # add new positions to any existing masks
 *             for segment in list(mask_segments) + self._mask_segments:             # <<<<<<<<<<<<<<
 *                 positions |= set(range(segment.start,segment.end))
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1838
 * 
 *             # trim away non-overlapping masks
 *             positions &= self.c_get_position_set()             # <<<<<<<<<<<<<<
 * 
 *             # regenerate list of segments from positions, in case some were doubly-listed
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_position_set(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyNumber_InPlaceAnd(__pyx_v_positions, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_positions, ((PyObject*)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":1841
 * 
 *             # regenerate list of segments from positions, in case some were doubly-listed
 *             new_segments = positions_to_segments(my_chrom,my_strand,positions)             # <<<<<<<<<<<<<<
 *             self._set_masks(new_segments)
 * 
 */
    __pyx_t_5 = __pyx_f_7plastid_8genomics_8roitools_positions_to_segments(__pyx_v_my_chrom, __pyx_v_my_strand, __pyx_v_positions, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_new_segments = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":1842
 *             # regenerate list of segments from positions, in case some were doubly-listed
 *             new_segments = positions_to_segments(my_chrom,my_strand,positions)
 *             self._set_masks(new_segments)             # <<<<<<<<<<<<<<
 * 
 *     cdef bint _set_masks(self, list segments) except False:
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->_set_masks(__pyx_v_self, __pyx_v_new_segments); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":1827
 *             list new_segments
 * 
 *         if len(mask_segments) > 0:             # <<<<<<<<<<<<<<
 *             check_segments(self,mask_segments)
 *             seg  = mask_segments[0]
 */
  }

  /* "plastid/genomics/roitools.pyx":1803
 * 
 *     # TODO: optimize
 *     def add_masks(self,*mask_segments):             # <<<<<<<<<<<<<<
 *         """Adds one or more |GenomicSegment| to the collection of masks.
 *         Masks will be trimmed to the positions of the |SegmentChain|
 */

  /* function exit code */
  __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_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.add_masks", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_my_chrom);
  __Pyx_XDECREF(__pyx_v_my_strand);
  __Pyx_XDECREF((PyObject *)__pyx_v_segment);
  __Pyx_XDECREF(__pyx_v_positions);
  __Pyx_XDECREF(__pyx_v_new_segments);
  __Pyx_XDECREF(__pyx_v_seg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1844
 *             self._set_masks(new_segments)
 * 
 *     cdef bint _set_masks(self, list segments) except False:             # <<<<<<<<<<<<<<
 *         """Set `self._mask_segments` and update mask hashes, assuming `segments`
 *         have passed the following criteria:
 */

static int __pyx_f_7plastid_8genomics_8roitools_12SegmentChain__set_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_segments) {
  arrayobject *__pyx_v_pmask = 0;
  __Pyx_memviewslice __pyx_v_pview = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_ihash = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg = 0;
  long __pyx_v_i;
  long __pyx_v_coord;
  int __pyx_v_tmpsum;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
  Py_ssize_t __pyx_t_4;
  long __pyx_t_5;
  long __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  long __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_set_masks", 0);

  /* "plastid/genomics/roitools.pyx":1866
 *         """
 *         cdef:
 *             array.array pmask = array.clone(mask_template,self.length,True)             # <<<<<<<<<<<<<<
 *             int [:] pview = pmask
 *             dict ihash = self._get_inverse_hash()
 */
  if (!(likely(((__pyx_v_7plastid_8genomics_8roitools_mask_template) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_7plastid_8genomics_8roitools_mask_template, __pyx_ptype_7cpython_5array_array))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_7plastid_8genomics_8roitools_mask_template;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((PyObject *)__pyx_f_7cpython_5array_clone(((arrayobject *)__pyx_t_1), __pyx_v_self->length, 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_pmask = ((arrayobject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1867
 *         cdef:
 *             array.array pmask = array.clone(mask_template,self.length,True)
 *             int [:] pview = pmask             # <<<<<<<<<<<<<<
 *             dict ihash = self._get_inverse_hash()
 *             list new_segments
 */
  __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(((PyObject *)__pyx_v_pmask));
  if (unlikely(!__pyx_t_3.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_pview = __pyx_t_3;
  __pyx_t_3.memview = NULL;
  __pyx_t_3.data = NULL;

  /* "plastid/genomics/roitools.pyx":1868
 *             array.array pmask = array.clone(mask_template,self.length,True)
 *             int [:] pview = pmask
 *             dict ihash = self._get_inverse_hash()             # <<<<<<<<<<<<<<
 *             list new_segments
 *             GenomicSegment seg
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->_get_inverse_hash(__pyx_v_self); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ihash = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1872
 *             GenomicSegment seg
 *             long i, coord
 *             int tmpsum = 0             # <<<<<<<<<<<<<<
 * 
 *         for seg in segments:
 */
  __pyx_v_tmpsum = 0;

  /* "plastid/genomics/roitools.pyx":1874
 *             int tmpsum = 0
 * 
 *         for seg in segments:             # <<<<<<<<<<<<<<
 *             for i in range(seg.start,seg.end):
 *                 coord = ihash[i]
 */
  if (unlikely(__pyx_v_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __pyx_v_segments; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_seg, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":1875
 * 
 *         for seg in segments:
 *             for i in range(seg.start,seg.end):             # <<<<<<<<<<<<<<
 *                 coord = ihash[i]
 *                 pview[coord] = 1
 */
    __pyx_t_5 = __pyx_v_seg->end;
    for (__pyx_t_6 = __pyx_v_seg->start; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "plastid/genomics/roitools.pyx":1876
 *         for seg in segments:
 *             for i in range(seg.start,seg.end):
 *                 coord = ihash[i]             # <<<<<<<<<<<<<<
 *                 pview[coord] = 1
 *                 tmpsum += 1
 */
      if (unlikely(__pyx_v_ihash == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_ihash, __pyx_t_1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = __Pyx_PyInt_As_long(__pyx_t_7); if (unlikely((__pyx_t_8 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_coord = __pyx_t_8;

      /* "plastid/genomics/roitools.pyx":1877
 *             for i in range(seg.start,seg.end):
 *                 coord = ihash[i]
 *                 pview[coord] = 1             # <<<<<<<<<<<<<<
 *                 tmpsum += 1
 * 
 */
      __pyx_t_9 = __pyx_v_coord;
      __pyx_t_10 = -1;
      if (__pyx_t_9 < 0) {
        __pyx_t_9 += __pyx_v_pview.shape[0];
        if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 0;
      } else if (unlikely(__pyx_t_9 >= __pyx_v_pview.shape[0])) __pyx_t_10 = 0;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      *((int *) ( /* dim=0 */ (__pyx_v_pview.data + __pyx_t_9 * __pyx_v_pview.strides[0]) )) = 1;

      /* "plastid/genomics/roitools.pyx":1878
 *                 coord = ihash[i]
 *                 pview[coord] = 1
 *                 tmpsum += 1             # <<<<<<<<<<<<<<
 * 
 *         self._mask_segments = segments
 */
      __pyx_v_tmpsum = (__pyx_v_tmpsum + 1);
    }

    /* "plastid/genomics/roitools.pyx":1874
 *             int tmpsum = 0
 * 
 *         for seg in segments:             # <<<<<<<<<<<<<<
 *             for i in range(seg.start,seg.end):
 *                 coord = ihash[i]
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1880
 *                 tmpsum += 1
 * 
 *         self._mask_segments = segments             # <<<<<<<<<<<<<<
 *         self.masked_length = self.length - tmpsum
 *         self._position_mask = pmask
 */
  __Pyx_INCREF(__pyx_v_segments);
  __Pyx_GIVEREF(__pyx_v_segments);
  __Pyx_GOTREF(__pyx_v_self->_mask_segments);
  __Pyx_DECREF(__pyx_v_self->_mask_segments);
  __pyx_v_self->_mask_segments = __pyx_v_segments;

  /* "plastid/genomics/roitools.pyx":1881
 * 
 *         self._mask_segments = segments
 *         self.masked_length = self.length - tmpsum             # <<<<<<<<<<<<<<
 *         self._position_mask = pmask
 *         return True
 */
  __pyx_v_self->masked_length = (__pyx_v_self->length - __pyx_v_tmpsum);

  /* "plastid/genomics/roitools.pyx":1882
 *         self._mask_segments = segments
 *         self.masked_length = self.length - tmpsum
 *         self._position_mask = pmask             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_pmask));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_pmask));
  __Pyx_GOTREF(__pyx_v_self->_position_mask);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_position_mask));
  __pyx_v_self->_position_mask = __pyx_v_pmask;

  /* "plastid/genomics/roitools.pyx":1883
 *         self.masked_length = self.length - tmpsum
 *         self._position_mask = pmask
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def get_masks(self):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1844
 *             self._set_masks(new_segments)
 * 
 *     cdef bint _set_masks(self, list segments) except False:             # <<<<<<<<<<<<<<
 *         """Set `self._mask_segments` and update mask hashes, assuming `segments`
 *         have passed the following criteria:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain._set_masks", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_pmask);
  __PYX_XDEC_MEMVIEW(&__pyx_v_pview, 1);
  __Pyx_XDECREF(__pyx_v_ihash);
  __Pyx_XDECREF((PyObject *)__pyx_v_seg);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1885
 *         return True
 * 
 *     def get_masks(self):             # <<<<<<<<<<<<<<
 *         """Return masked positions as a list of |GenomicSegments|
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_63get_masks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_62get_masks[] = "SegmentChain.get_masks(self)\nReturn masked positions as a list of |GenomicSegments|\n        \n        Returns\n        -------\n        list\n            list of |GenomicSegments| representing masked positions\n        \n        See also\n        --------\n        SegmentChain.get_masks_as_segmentchain\n        \n        SegmentChain.add_masks\n        \n        SegmentChain.reset_masks\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_63get_masks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_masks (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_62get_masks(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_62get_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("get_masks", 0);

  /* "plastid/genomics/roitools.pyx":1901
 *         SegmentChain.reset_masks
 *         """
 *         return copy.copy(self._mask_segments)             # <<<<<<<<<<<<<<
 * 
 *     def get_masks_as_segmentchain(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); 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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->_mask_segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); 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_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->_mask_segments);
    __Pyx_GIVEREF(__pyx_v_self->_mask_segments);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->_mask_segments);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1885
 *         return True
 * 
 *     def get_masks(self):             # <<<<<<<<<<<<<<
 *         """Return masked positions as a list of |GenomicSegments|
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.get_masks", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1903
 *         return copy.copy(self._mask_segments)
 * 
 *     def get_masks_as_segmentchain(self):             # <<<<<<<<<<<<<<
 *         """Return masked positions as a |SegmentChain|
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_65get_masks_as_segmentchain(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_64get_masks_as_segmentchain[] = "SegmentChain.get_masks_as_segmentchain(self)\nReturn masked positions as a |SegmentChain|\n        \n        Returns\n        -------\n        |SegmentChain|\n            Masked positions\n        \n        See also\n        --------\n        SegmentChain.get_masks\n        \n        SegmentChain.add_masks\n\n        SegmentChain.reset_masks\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_65get_masks_as_segmentchain(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_masks_as_segmentchain (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_64get_masks_as_segmentchain(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_64get_masks_as_segmentchain(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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("get_masks_as_segmentchain", 0);

  /* "plastid/genomics/roitools.pyx":1919
 *         SegmentChain.reset_masks
 *         """
 *         return SegmentChain(*self._mask_segments)             # <<<<<<<<<<<<<<
 * 
 *     cdef void c_reset_masks(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_Tuple(__pyx_v_self->_mask_segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __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;

  /* "plastid/genomics/roitools.pyx":1903
 *         return copy.copy(self._mask_segments)
 * 
 *     def get_masks_as_segmentchain(self):             # <<<<<<<<<<<<<<
 *         """Return masked positions as a |SegmentChain|
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_masks_as_segmentchain", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1921
 *         return SegmentChain(*self._mask_segments)
 * 
 *     cdef void c_reset_masks(self):             # <<<<<<<<<<<<<<
 *         cdef int [:] pmask = self._position_mask
 *         pmask [:] = 0
 */

static void __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_reset_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  __Pyx_memviewslice __pyx_v_pmask = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_RefNannyDeclarations
  __Pyx_memviewslice __pyx_t_1 = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_t_2 = NULL;
  long __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("c_reset_masks", 0);

  /* "plastid/genomics/roitools.pyx":1922
 * 
 *     cdef void c_reset_masks(self):
 *         cdef int [:] pmask = self._position_mask             # <<<<<<<<<<<<<<
 *         pmask [:] = 0
 *         self._mask_segments = []
 */
  __pyx_t_1 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(((PyObject *)__pyx_v_self->_position_mask));
  if (unlikely(!__pyx_t_1.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_pmask = __pyx_t_1;
  __pyx_t_1.memview = NULL;
  __pyx_t_1.data = NULL;

  /* "plastid/genomics/roitools.pyx":1923
 *     cdef void c_reset_masks(self):
 *         cdef int [:] pmask = self._position_mask
 *         pmask [:] = 0             # <<<<<<<<<<<<<<
 *         self._mask_segments = []
 *         self.masked_length = self.length
 */
  __pyx_t_1.data = __pyx_v_pmask.data;
  __pyx_t_1.memview = __pyx_v_pmask.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_1, 0);
  __pyx_t_1.shape[0] = __pyx_v_pmask.shape[0];
__pyx_t_1.strides[0] = __pyx_v_pmask.strides[0];
    __pyx_t_1.suboffsets[0] = -1;

{
      int __pyx_temp_scalar = 0;
      {
          Py_ssize_t __pyx_temp_extent_0 = __pyx_t_1.shape[0];
          Py_ssize_t __pyx_temp_stride_0 = __pyx_t_1.strides[0];
          char *__pyx_temp_pointer_0;
          Py_ssize_t __pyx_temp_idx_0;
          __pyx_temp_pointer_0 = __pyx_t_1.data;
          for (__pyx_temp_idx_0 = 0; __pyx_temp_idx_0 < __pyx_temp_extent_0; __pyx_temp_idx_0++) {
            *((int *) __pyx_temp_pointer_0) = __pyx_temp_scalar;
            __pyx_temp_pointer_0 += __pyx_temp_stride_0;
          }
      }
  }
  __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);

  /* "plastid/genomics/roitools.pyx":1924
 *         cdef int [:] pmask = self._position_mask
 *         pmask [:] = 0
 *         self._mask_segments = []             # <<<<<<<<<<<<<<
 *         self.masked_length = self.length
 * 
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->_mask_segments);
  __Pyx_DECREF(__pyx_v_self->_mask_segments);
  __pyx_v_self->_mask_segments = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":1925
 *         pmask [:] = 0
 *         self._mask_segments = []
 *         self.masked_length = self.length             # <<<<<<<<<<<<<<
 * 
 *     def reset_masks(self):
 */
  __pyx_t_3 = __pyx_v_self->length;
  __pyx_v_self->masked_length = __pyx_t_3;

  /* "plastid/genomics/roitools.pyx":1921
 *         return SegmentChain(*self._mask_segments)
 * 
 *     cdef void c_reset_masks(self):             # <<<<<<<<<<<<<<
 *         cdef int [:] pmask = self._position_mask
 *         pmask [:] = 0
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_WriteUnraisable("plastid.genomics.roitools.SegmentChain.c_reset_masks", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_pmask, 1);
  __Pyx_RefNannyFinishContext();
}

/* "plastid/genomics/roitools.pyx":1927
 *         self.masked_length = self.length
 * 
 *     def reset_masks(self):             # <<<<<<<<<<<<<<
 *         """Removes masks added by :py:meth:`add_masks`
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_67reset_masks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_66reset_masks[] = "SegmentChain.reset_masks(self)\nRemoves masks added by :py:meth:`add_masks`\n\n        See also\n        --------\n        SegmentChain.add_masks\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_67reset_masks(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset_masks (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_66reset_masks(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_66reset_masks(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset_masks", 0);

  /* "plastid/genomics/roitools.pyx":1934
 *         SegmentChain.add_masks
 *         """
 *         self.c_reset_masks()             # <<<<<<<<<<<<<<
 * 
 *     def get_junctions(self):
 */
  ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_reset_masks(__pyx_v_self);

  /* "plastid/genomics/roitools.pyx":1927
 *         self.masked_length = self.length
 * 
 *     def reset_masks(self):             # <<<<<<<<<<<<<<
 *         """Removes masks added by :py:meth:`add_masks`
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1936
 *         self.c_reset_masks()
 * 
 *     def get_junctions(self):             # <<<<<<<<<<<<<<
 *         """Returns a list of |GenomicSegments| representing spaces
 *         between the |GenomicSegments| in `self` In the case of a transcript,
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_69get_junctions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_68get_junctions[] = "SegmentChain.get_junctions(self)\nReturns a list of |GenomicSegments| representing spaces\n        between the |GenomicSegments| in `self` In the case of a transcript,\n        these would represent introns. In the case of an alignment, these\n        would represent gaps in the query compared to the reference.\n        \n        Returns\n        -------\n        list\n            List of |GenomicSegments| covering spaces between the intervals in `self`\n            (e.g. introns in the case of a transcript, or gaps in the case of\n            an alignment)\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_69get_junctions(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_junctions (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_68get_junctions(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_68get_junctions(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg1 = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg2 = 0;
  PyObject *__pyx_v_juncs = 0;
  int __pyx_v_i;
  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;
  long __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  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("get_junctions", 0);

  /* "plastid/genomics/roitools.pyx":1951
 *         cdef:
 *             GenomicSegment seg1, seg2
 *             list juncs = []             # <<<<<<<<<<<<<<
 *             int i
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_juncs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":1954
 *             int i
 * 
 *         for i in range(len(self._segments)-1):             # <<<<<<<<<<<<<<
 *             seg1, seg2 = self._segments[i], self._segments[i+1]
 *             juncs.append(GenomicSegment(seg1.chrom,
 */
  __pyx_t_1 = __pyx_v_self->_segments;
  __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 = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 - 1);
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "plastid/genomics/roitools.pyx":1955
 * 
 *         for i in range(len(self._segments)-1):
 *             seg1, seg2 = self._segments[i], self._segments[i+1]             # <<<<<<<<<<<<<<
 *             juncs.append(GenomicSegment(seg1.chrom,
 *                                         seg1.end,
 */
    if (unlikely(__pyx_v_self->_segments == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->_segments, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1955; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(__pyx_v_self->_segments == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = (__pyx_v_i + 1);
    __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_self->_segments, __pyx_t_5, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1955; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_seg1, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1));
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_seg2, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":1957
 *             seg1, seg2 = self._segments[i], self._segments[i+1]
 *             juncs.append(GenomicSegment(seg1.chrom,
 *                                         seg1.end,             # <<<<<<<<<<<<<<
 *                                         seg2.start,
 *                                         seg1.strand))
 */
    __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_seg1->end); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "plastid/genomics/roitools.pyx":1958
 *             juncs.append(GenomicSegment(seg1.chrom,
 *                                         seg1.end,
 *                                         seg2.start,             # <<<<<<<<<<<<<<
 *                                         seg1.strand))
 *         return juncs
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_seg2->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);

    /* "plastid/genomics/roitools.pyx":1959
 *                                         seg1.end,
 *                                         seg2.start,
 *                                         seg1.strand))             # <<<<<<<<<<<<<<
 *         return juncs
 * 
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_seg1), __pyx_n_s_strand); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);

    /* "plastid/genomics/roitools.pyx":1956
 *         for i in range(len(self._segments)-1):
 *             seg1, seg2 = self._segments[i], self._segments[i+1]
 *             juncs.append(GenomicSegment(seg1.chrom,             # <<<<<<<<<<<<<<
 *                                         seg1.end,
 *                                         seg2.start,
 */
    __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_seg1->chrom);
    __Pyx_GIVEREF(__pyx_v_seg1->chrom);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_seg1->chrom);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_juncs, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }

  /* "plastid/genomics/roitools.pyx":1960
 *                                         seg2.start,
 *                                         seg1.strand))
 *         return juncs             # <<<<<<<<<<<<<<
 * 
 *     # TODO: test optimality
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_juncs);
  __pyx_r = __pyx_v_juncs;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1936
 *         self.c_reset_masks()
 * 
 *     def get_junctions(self):             # <<<<<<<<<<<<<<
 *         """Returns a list of |GenomicSegments| representing spaces
 *         between the |GenomicSegments| in `self` In the case of a transcript,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_junctions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_seg1);
  __Pyx_XDECREF((PyObject *)__pyx_v_seg2);
  __Pyx_XDECREF(__pyx_v_juncs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":1963
 * 
 *     # TODO: test optimality
 *     def as_gff3(self, str feature_type=None, bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format a length-1 |SegmentChain| as a line of `GFF3`_ output.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_71as_gff3(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_70as_gff3[] = "SegmentChain.as_gff3(self, str feature_type=None, bool escape=True, list excludes=[])\nFormat a length-1 |SegmentChain| as a line of `GFF3`_ output.\n        \n        Because `GFF3`_ files permit many schemas of parent-child hierarchy,\n        and in order to reduce confusion and overhead, attempts to export\n        a multi-interval |SegmentChain| will raise an :py:obj:`AttributeError`.\n        \n        Instead, users may export the individual features from which the\n        multi-interval |SegmentChain| was constructed, or construct features\n        for them, setting *ID*, *Parent*, and *type* attributes following\n        their own conventions.\n\n         \n        Parameters\n        ----------\n        feature_type : str\n            If not None, overrides the `type` attribute of `self.attr`\n        \n        escape : bool, optional\n            Escape tokens in column 9 of `GFF3`_ output (Default: `True*)\n        \n        excludes : list, optional\n            List of attribute key names to exclude from column 9\n            (Default: `[]`)\n        \n        Returns\n        -------\n        str\n            Line of `GFF3`_-formatted text\n        \n            \n        Raises\n        -----\n        AttributeError\n            if the |SegmentChain| has multiple intervals\n            \n        Notes\n        -----\n        Columns of `GFF3`_ are as follows\n            ======== =========\n            Column   Contains\n            ======== =========\n                1     Contig or chromosome \n                2     Source of annotation \n                3     Type of feature (\"exon\", \"CDS\", \"start_codon\", \"stop_codon\") \n                4     Start (1-indexed)  \n                5     End (fully-closed)\n                6     Score  \n                7     Strand  \n                8     Frame. Number of bases within feature before first in-frame codon (if coding) \n                9     Attributes                       \n            ====""==== =========\n\n        For futher information, see\n            - `GFF3 file format specification <http://www.sequenceontology.org/gff3.shtml>`_\n            - `Sequence Ontology (SO) v2.53 <http://www.sequenceontology.org/browser/>`_\n            - `SO releases <http://sourceforge.net/projects/song/files/SO_Feature_Annotation/>`_\n            - `UCSC file format FAQ <http://genome.ucsc.edu/FAQ/FAQformat.html>`_            \n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_71as_gff3(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_feature_type = 0;
  CYTHON_UNUSED int __pyx_v_escape;
  PyObject *__pyx_v_excludes = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_gff3 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_feature_type,&__pyx_n_s_escape,&__pyx_n_s_excludes,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject*)Py_None);
    values[2] = __pyx_k__15;
    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_feature_type);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_escape);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_excludes);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "as_gff3") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1963; __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_feature_type = ((PyObject*)values[0]);
    if (values[1]) {
      __pyx_v_escape = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_escape == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1963; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_escape = ((int)1);
    }
    __pyx_v_excludes = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("as_gff3", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1963; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_gff3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature_type), (&PyString_Type), 1, "feature_type", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_excludes), (&PyList_Type), 1, "excludes", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_70as_gff3(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_feature_type, __pyx_v_escape, __pyx_v_excludes);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_70as_gff3(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_feature_type, CYTHON_UNUSED int __pyx_v_escape, PyObject *__pyx_v_excludes) {
  PyObject *__pyx_v_gff_attr = 0;
  PyObject *__pyx_v_always_excluded = 0;
  PyObject *__pyx_v_ltmp = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_segment = 0;
  int __pyx_v_length;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("as_gff3", 0);
  __Pyx_INCREF(__pyx_v_feature_type);

  /* "plastid/genomics/roitools.pyx":2026
 *             list always_excluded, ltmp
 *             GenomicSegment segment
 *             int length = len(self._segments)             # <<<<<<<<<<<<<<
 * 
 *         if length == 0: # empty SegmentChain
 */
  __pyx_t_1 = __pyx_v_self->_segments;
  __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 = 2026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_length = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":2028
 *             int length = len(self._segments)
 * 
 *         if length == 0: # empty SegmentChain             # <<<<<<<<<<<<<<
 *             return ""
 *         elif length > 1:
 */
  __pyx_t_3 = ((__pyx_v_length == 0) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2029
 * 
 *         if length == 0: # empty SegmentChain
 *             return ""             # <<<<<<<<<<<<<<
 *         elif length > 1:
 *             raise AttributeError("Attempted export of multi-interval %s" % self.__class__)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__16);
    __pyx_r = __pyx_kp_s__16;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":2028
 *             int length = len(self._segments)
 * 
 *         if length == 0: # empty SegmentChain             # <<<<<<<<<<<<<<
 *             return ""
 *         elif length > 1:
 */
  }

  /* "plastid/genomics/roitools.pyx":2030
 *         if length == 0: # empty SegmentChain
 *             return ""
 *         elif length > 1:             # <<<<<<<<<<<<<<
 *             raise AttributeError("Attempted export of multi-interval %s" % self.__class__)
 * 
 */
  __pyx_t_3 = ((__pyx_v_length > 1) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2031
 *             return ""
 *         elif length > 1:
 *             raise AttributeError("Attempted export of multi-interval %s" % self.__class__)             # <<<<<<<<<<<<<<
 * 
 *         gff_attr = copy.deepcopy(self.attr)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Attempted_export_of_multi_interv, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __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 = 2031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 2031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2030
 *         if length == 0: # empty SegmentChain
 *             return ""
 *         elif length > 1:             # <<<<<<<<<<<<<<
 *             raise AttributeError("Attempted export of multi-interval %s" % self.__class__)
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2033
 *             raise AttributeError("Attempted export of multi-interval %s" % self.__class__)
 * 
 *         gff_attr = copy.deepcopy(self.attr)             # <<<<<<<<<<<<<<
 *         feature_type = self.attr["type"] if feature_type is None else feature_type
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->attr); 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);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
    __Pyx_INCREF(__pyx_v_self->attr);
    __Pyx_GIVEREF(__pyx_v_self->attr);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_self->attr);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); 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_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2033; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_gff_attr = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":2034
 * 
 *         gff_attr = copy.deepcopy(self.attr)
 *         feature_type = self.attr["type"] if feature_type is None else feature_type             # <<<<<<<<<<<<<<
 * 
 *         always_excluded = ["source",
 */
  __pyx_t_3 = (__pyx_v_feature_type == ((PyObject*)Py_None));
  if ((__pyx_t_3 != 0)) {
    if (unlikely(__pyx_v_self->attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_self->attr, __pyx_n_s_type); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(__pyx_v_feature_type);
    __pyx_t_4 = __pyx_v_feature_type;
  }
  __Pyx_DECREF_SET(__pyx_v_feature_type, ((PyObject*)__pyx_t_4));
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":2036
 *         feature_type = self.attr["type"] if feature_type is None else feature_type
 * 
 *         always_excluded = ["source",             # <<<<<<<<<<<<<<
 *                            "score",
 *                            "phase",
 */
  __pyx_t_4 = PyList_New(9); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_n_s_source);
  __Pyx_GIVEREF(__pyx_n_s_source);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_source);
  __Pyx_INCREF(__pyx_n_s_score);
  __Pyx_GIVEREF(__pyx_n_s_score);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_score);
  __Pyx_INCREF(__pyx_n_s_phase);
  __Pyx_GIVEREF(__pyx_n_s_phase);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_s_phase);
  __Pyx_INCREF(__pyx_n_s_cds_genome_start);
  __Pyx_GIVEREF(__pyx_n_s_cds_genome_start);
  PyList_SET_ITEM(__pyx_t_4, 3, __pyx_n_s_cds_genome_start);
  __Pyx_INCREF(__pyx_n_s_cds_genome_end);
  __Pyx_GIVEREF(__pyx_n_s_cds_genome_end);
  PyList_SET_ITEM(__pyx_t_4, 4, __pyx_n_s_cds_genome_end);
  __Pyx_INCREF(__pyx_n_s_thickstart);
  __Pyx_GIVEREF(__pyx_n_s_thickstart);
  PyList_SET_ITEM(__pyx_t_4, 5, __pyx_n_s_thickstart);
  __Pyx_INCREF(__pyx_n_s_thickend);
  __Pyx_GIVEREF(__pyx_n_s_thickend);
  PyList_SET_ITEM(__pyx_t_4, 6, __pyx_n_s_thickend);
  __Pyx_INCREF(__pyx_n_s_type);
  __Pyx_GIVEREF(__pyx_n_s_type);
  PyList_SET_ITEM(__pyx_t_4, 7, __pyx_n_s_type);
  __Pyx_INCREF(__pyx_n_s_bedx_column_order);
  __Pyx_GIVEREF(__pyx_n_s_bedx_column_order);
  PyList_SET_ITEM(__pyx_t_4, 8, __pyx_n_s_bedx_column_order);
  __pyx_v_always_excluded = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":2046
 *                            "_bedx_column_order"]
 * 
 *         for segment in self:             # <<<<<<<<<<<<<<
 *             ltmp = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GFF3_tokens(gff_attr,
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
    __pyx_t_4 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_7(__pyx_t_4);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_segment, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":2047
 * 
 *         for segment in self:
 *             ltmp = self._get_8_gff_columns(segment,feature_type) +\             # <<<<<<<<<<<<<<
 *                    [make_GFF3_tokens(gff_attr,
 *                                      excludes=always_excluded+excludes,
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_8_gff_columns); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_segment));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_segment));
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, ((PyObject *)__pyx_v_segment));
    __Pyx_INCREF(__pyx_v_feature_type);
    __Pyx_GIVEREF(__pyx_v_feature_type);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_feature_type);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":2048
 *         for segment in self:
 *             ltmp = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GFF3_tokens(gff_attr,             # <<<<<<<<<<<<<<
 *                                      excludes=always_excluded+excludes,
 *                                      escape=True)]
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_make_GFF3_tokens); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_gff_attr);
    __Pyx_GIVEREF(__pyx_v_gff_attr);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_gff_attr);

    /* "plastid/genomics/roitools.pyx":2049
 *             ltmp = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GFF3_tokens(gff_attr,
 *                                      excludes=always_excluded+excludes,             # <<<<<<<<<<<<<<
 *                                      escape=True)]
 * 
 */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = PyNumber_Add(__pyx_v_always_excluded, __pyx_v_excludes); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_excludes, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2050
 *                    [make_GFF3_tokens(gff_attr,
 *                                      excludes=always_excluded+excludes,
 *                                      escape=True)]             # <<<<<<<<<<<<<<
 * 
 *         return "\t".join(ltmp) + "\n"
 */
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_escape, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2048
 *         for segment in self:
 *             ltmp = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GFF3_tokens(gff_attr,             # <<<<<<<<<<<<<<
 *                                      excludes=always_excluded+excludes,
 *                                      escape=True)]
 */
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_10);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2047
 * 
 *         for segment in self:
 *             ltmp = self._get_8_gff_columns(segment,feature_type) +\             # <<<<<<<<<<<<<<
 *                    [make_GFF3_tokens(gff_attr,
 *                                      excludes=always_excluded+excludes,
 */
    __pyx_t_10 = PyNumber_Add(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_10))||((__pyx_t_10) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_10)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_ltmp, ((PyObject*)__pyx_t_10));
    __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2046
 *                            "_bedx_column_order"]
 * 
 *         for segment in self:             # <<<<<<<<<<<<<<
 *             ltmp = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GFF3_tokens(gff_attr,
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":2052
 *                                      escape=True)]
 * 
 *         return "\t".join(ltmp) + "\n"             # <<<<<<<<<<<<<<
 * 
 *     # TODO: optimize
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_ltmp)) { __Pyx_RaiseUnboundLocalError("ltmp"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_4 = __Pyx_PyString_Join(__pyx_kp_s__17, __pyx_v_ltmp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = PyNumber_Add(__pyx_t_4, __pyx_kp_s__18); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_10;
  __pyx_t_10 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":1963
 * 
 *     # TODO: test optimality
 *     def as_gff3(self, str feature_type=None, bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format a length-1 |SegmentChain| as a line of `GFF3`_ output.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_gff3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gff_attr);
  __Pyx_XDECREF(__pyx_v_always_excluded);
  __Pyx_XDECREF(__pyx_v_ltmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_segment);
  __Pyx_XDECREF(__pyx_v_feature_type);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2055
 * 
 *     # TODO: optimize
 *     def as_gtf(self, str feature_type=None, bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format |SegmentChain| as a block of `GTF2`_ output.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_73as_gtf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_72as_gtf[] = "SegmentChain.as_gtf(self, str feature_type=None, bool escape=True, list excludes=[])\nFormat |SegmentChain| as a block of `GTF2`_ output.\n        \n        The `frame` or `phase` attribute (`GTF2`_ column 8) is valid only for `'CDS'`\n        features, and, if not present in `self.attr`, is calculated assuming\n        the |SegmentChain| contains the entire coding region. If the |SegmentChain|\n        contains multiple intervals, the `frame` or `phase` attribute will\n        *always* be recalculated.\n        \n        All attributes in `self.attr`, except those created upon import,\n        will be propagated to all of the features that are generated.\n        \n        Parameters\n        ----------\n        feature_type : str\n            If not None, overrides the \"type\" attribute of ``self.attr``\n        \n        escape : bool, optional\n            Escape tokens in column 9 of GTF output (Default: True)\n        \n        excludes : list, optional\n            List of attribute key names to exclude from column 8\n            (Default: *[]*)\n        \n        Returns\n        -------\n        str\n            Block of GTF2-formatted text\n        \n        \n        Notes\n        -----\n        `gene_id` and `transcript_id` are required\n            The `GTF2 specification <http://mblab.wustl.edu/GTF22.html>`_ requires\n            that attributes `gene_id` and `transcript_id` be defined. If these\n            are not present in `self.attr`, their values will be guessed \n            following the rules in :py:meth:`SegmentChain.get_gene` and \n            :py:meth:`SegmentChain.get_name`, respectively.\n        \n        Beware of attribute loss\n            To save memory, only the attributes shared by all of the individual\n            sub-features (e.g. exons) that were used to assemble this |Transcript|\n            have been stored in `self.attr`. This means that upon re-export to `GTF2`_,\n            these sub-features will be lacking any attri""butes that were specific\n            to them individually. Formally, this is compliant with the \n            `GTF2 specification <http://mblab.wustl.edu/GTF22.html>`_, which states\n            explicitly that only the attributes `gene_id` and `transcript_id`\n            are supported.\n            \n        Columns of `GTF2`_ are as follows\n            ======== =========\n            Column   Contains\n            ======== =========\n                1     Contig or chromosome \n                2     Source of annotation \n                3     Type of feature (\"exon\", \"CDS\", \"start_codon\", \"stop_codon\") \n                4     Start (1-indexed)  \n                5     End (fully-closed)\n                6     Score  \n                7     Strand  \n                8     Frame. Number of bases within feature before first in-frame codon (if coding) \n                9     Attributes. \"gene_id\" and \"transcript_id\" are required                        \n            ======== =========\n        \n        For more info\n            - `GTF2 file format specification <http://mblab.wustl.edu/GTF22.html>`_\n            - `UCSC file format FAQ <http://genome.ucsc.edu/FAQ/FAQformat.html>`_           \n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_73as_gtf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_feature_type = 0;
  int __pyx_v_escape;
  PyObject *__pyx_v_excludes = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_gtf (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_feature_type,&__pyx_n_s_escape,&__pyx_n_s_excludes,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject*)Py_None);
    values[2] = __pyx_k__19;
    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_feature_type);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_escape);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_excludes);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "as_gtf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __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_feature_type = ((PyObject*)values[0]);
    if (values[1]) {
      __pyx_v_escape = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_escape == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_escape = ((int)1);
    }
    __pyx_v_excludes = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("as_gtf", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_gtf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature_type), (&PyString_Type), 1, "feature_type", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_excludes), (&PyList_Type), 1, "excludes", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_72as_gtf(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_feature_type, __pyx_v_escape, __pyx_v_excludes);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_72as_gtf(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_feature_type, int __pyx_v_escape, PyObject *__pyx_v_excludes) {
  PyObject *__pyx_v_gtf_attr = 0;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_v_ltmp1 = 0;
  PyObject *__pyx_v_ltmp2 = 0;
  PyObject *__pyx_v_always_excluded = 0;
  PyObject *__pyx_v_segment = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("as_gtf", 0);
  __Pyx_INCREF(__pyx_v_feature_type);

  /* "plastid/genomics/roitools.pyx":2125
 *         cdef:
 *             dict gtf_attr
 *             dict attr = self.attr             # <<<<<<<<<<<<<<
 *             list ltmp1, ltmp2, always_excluded
 * 
 */
  __pyx_t_1 = __pyx_v_self->attr;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2128
 *             list ltmp1, ltmp2, always_excluded
 * 
 *         if len(self) == 0:             # <<<<<<<<<<<<<<
 *             return ""
 * 
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((__pyx_t_2 == 0) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2129
 * 
 *         if len(self) == 0:
 *             return ""             # <<<<<<<<<<<<<<
 * 
 *         gtf_attr = copy.deepcopy(attr)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__16);
    __pyx_r = __pyx_kp_s__16;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":2128
 *             list ltmp1, ltmp2, always_excluded
 * 
 *         if len(self) == 0:             # <<<<<<<<<<<<<<
 *             return ""
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2131
 *             return ""
 * 
 *         gtf_attr = copy.deepcopy(attr)             # <<<<<<<<<<<<<<
 *         gtf_attr["transcript_id"] = attr.get("transcript_id",self.get_name())
 *         gtf_attr["gene_id"]       = attr.get("gene_id",self.get_gene())
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); 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_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_attr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_attr);
    __Pyx_GIVEREF(__pyx_v_attr);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_attr);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_gtf_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2132
 * 
 *         gtf_attr = copy.deepcopy(attr)
 *         gtf_attr["transcript_id"] = attr.get("transcript_id",self.get_name())             # <<<<<<<<<<<<<<
 *         gtf_attr["gene_id"]       = attr.get("gene_id",self.get_gene())
 *         feature_type = attr["type"] if feature_type is None else feature_type
 */
  if (unlikely(__pyx_v_attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyDict_GetItemDefault(__pyx_v_attr, __pyx_n_s_transcript_id, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_v_gtf_attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(PyDict_SetItem(__pyx_v_gtf_attr, __pyx_n_s_transcript_id, __pyx_t_5) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "plastid/genomics/roitools.pyx":2133
 *         gtf_attr = copy.deepcopy(attr)
 *         gtf_attr["transcript_id"] = attr.get("transcript_id",self.get_name())
 *         gtf_attr["gene_id"]       = attr.get("gene_id",self.get_gene())             # <<<<<<<<<<<<<<
 *         feature_type = attr["type"] if feature_type is None else feature_type
 * 
 */
  if (unlikely(__pyx_v_attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_gene); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_attr, __pyx_n_s_gene_id, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(__pyx_v_gtf_attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(PyDict_SetItem(__pyx_v_gtf_attr, __pyx_n_s_gene_id, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2134
 *         gtf_attr["transcript_id"] = attr.get("transcript_id",self.get_name())
 *         gtf_attr["gene_id"]       = attr.get("gene_id",self.get_gene())
 *         feature_type = attr["type"] if feature_type is None else feature_type             # <<<<<<<<<<<<<<
 * 
 *         ltmp1 = []
 */
  __pyx_t_3 = (__pyx_v_feature_type == ((PyObject*)Py_None));
  if ((__pyx_t_3 != 0)) {
    if (unlikely(__pyx_v_attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_type); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __Pyx_INCREF(__pyx_v_feature_type);
    __pyx_t_1 = __pyx_v_feature_type;
  }
  __Pyx_DECREF_SET(__pyx_v_feature_type, ((PyObject*)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2136
 *         feature_type = attr["type"] if feature_type is None else feature_type
 * 
 *         ltmp1 = []             # <<<<<<<<<<<<<<
 * 
 *         always_excluded = ["source",
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ltmp1 = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2138
 *         ltmp1 = []
 * 
 *         always_excluded = ["source",             # <<<<<<<<<<<<<<
 *                            "Parent",
 *                            "score",
 */
  __pyx_t_1 = PyList_New(11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_source);
  __Pyx_GIVEREF(__pyx_n_s_source);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_source);
  __Pyx_INCREF(__pyx_n_s_Parent);
  __Pyx_GIVEREF(__pyx_n_s_Parent);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_Parent);
  __Pyx_INCREF(__pyx_n_s_score);
  __Pyx_GIVEREF(__pyx_n_s_score);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_score);
  __Pyx_INCREF(__pyx_n_s_phase);
  __Pyx_GIVEREF(__pyx_n_s_phase);
  PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_phase);
  __Pyx_INCREF(__pyx_n_s_cds_genome_start);
  __Pyx_GIVEREF(__pyx_n_s_cds_genome_start);
  PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_cds_genome_start);
  __Pyx_INCREF(__pyx_n_s_cds_genome_end);
  __Pyx_GIVEREF(__pyx_n_s_cds_genome_end);
  PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_cds_genome_end);
  __Pyx_INCREF(__pyx_n_s_thickstart);
  __Pyx_GIVEREF(__pyx_n_s_thickstart);
  PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_thickstart);
  __Pyx_INCREF(__pyx_n_s_thickend);
  __Pyx_GIVEREF(__pyx_n_s_thickend);
  PyList_SET_ITEM(__pyx_t_1, 7, __pyx_n_s_thickend);
  __Pyx_INCREF(__pyx_n_s_type);
  __Pyx_GIVEREF(__pyx_n_s_type);
  PyList_SET_ITEM(__pyx_t_1, 8, __pyx_n_s_type);
  __Pyx_INCREF(__pyx_n_s_color);
  __Pyx_GIVEREF(__pyx_n_s_color);
  PyList_SET_ITEM(__pyx_t_1, 9, __pyx_n_s_color);
  __Pyx_INCREF(__pyx_n_s_bedx_column_order);
  __Pyx_GIVEREF(__pyx_n_s_bedx_column_order);
  PyList_SET_ITEM(__pyx_t_1, 10, __pyx_n_s_bedx_column_order);
  __pyx_v_always_excluded = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2150
 *                            "_bedx_column_order"]
 * 
 *         for segment in self:             # <<<<<<<<<<<<<<
 *             ltmp2 = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GTF2_tokens(gtf_attr,
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
    __pyx_t_1 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_segment, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":2151
 * 
 *         for segment in self:
 *             ltmp2 = self._get_8_gff_columns(segment,feature_type) +\             # <<<<<<<<<<<<<<
 *                    [make_GTF2_tokens(gtf_attr,
 *                                      excludes=always_excluded+excludes,
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_8_gff_columns); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_segment);
    __Pyx_GIVEREF(__pyx_v_segment);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_segment);
    __Pyx_INCREF(__pyx_v_feature_type);
    __Pyx_GIVEREF(__pyx_v_feature_type);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_feature_type);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":2152
 *         for segment in self:
 *             ltmp2 = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GTF2_tokens(gtf_attr,             # <<<<<<<<<<<<<<
 *                                      excludes=always_excluded+excludes,
 *                                      escape=escape)]
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_make_GTF2_tokens); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_gtf_attr);
    __Pyx_GIVEREF(__pyx_v_gtf_attr);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_gtf_attr);

    /* "plastid/genomics/roitools.pyx":2153
 *             ltmp2 = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GTF2_tokens(gtf_attr,
 *                                      excludes=always_excluded+excludes,             # <<<<<<<<<<<<<<
 *                                      escape=escape)]
 * 
 */
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = PyNumber_Add(__pyx_v_always_excluded, __pyx_v_excludes); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_excludes, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2154
 *                    [make_GTF2_tokens(gtf_attr,
 *                                      excludes=always_excluded+excludes,
 *                                      escape=escape)]             # <<<<<<<<<<<<<<
 * 
 *             ltmp1.append("\t".join(ltmp2))
 */
    __pyx_t_10 = __Pyx_PyBool_FromLong(__pyx_v_escape); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_escape, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2152
 *         for segment in self:
 *             ltmp2 = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GTF2_tokens(gtf_attr,             # <<<<<<<<<<<<<<
 *                                      excludes=always_excluded+excludes,
 *                                      escape=escape)]
 */
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_10);
    PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2151
 * 
 *         for segment in self:
 *             ltmp2 = self._get_8_gff_columns(segment,feature_type) +\             # <<<<<<<<<<<<<<
 *                    [make_GTF2_tokens(gtf_attr,
 *                                      excludes=always_excluded+excludes,
 */
    __pyx_t_10 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_10))||((__pyx_t_10) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_10)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_ltmp2, ((PyObject*)__pyx_t_10));
    __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2156
 *                                      escape=escape)]
 * 
 *             ltmp1.append("\t".join(ltmp2))             # <<<<<<<<<<<<<<
 * 
 *         return "\n".join(ltmp1) + "\n"
 */
    __pyx_t_10 = __Pyx_PyString_Join(__pyx_kp_s__17, __pyx_v_ltmp2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_ltmp1, __pyx_t_10); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2150
 *                            "_bedx_column_order"]
 * 
 *         for segment in self:             # <<<<<<<<<<<<<<
 *             ltmp2 = self._get_8_gff_columns(segment,feature_type) +\
 *                    [make_GTF2_tokens(gtf_attr,
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2158
 *             ltmp1.append("\t".join(ltmp2))
 * 
 *         return "\n".join(ltmp1) + "\n"             # <<<<<<<<<<<<<<
 * 
 *     # TODO: test optimality
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__18, __pyx_v_ltmp1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = PyNumber_Add(__pyx_t_1, __pyx_kp_s__18); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_10;
  __pyx_t_10 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2055
 * 
 *     # TODO: optimize
 *     def as_gtf(self, str feature_type=None, bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format |SegmentChain| as a block of `GTF2`_ output.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_gtf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gtf_attr);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_ltmp1);
  __Pyx_XDECREF(__pyx_v_ltmp2);
  __Pyx_XDECREF(__pyx_v_always_excluded);
  __Pyx_XDECREF(__pyx_v_segment);
  __Pyx_XDECREF(__pyx_v_feature_type);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2161
 * 
 *     # TODO: test optimality
 *     def _get_8_gff_columns(self, GenomicSegment segment, str feature_type):             # <<<<<<<<<<<<<<
 *         """Format columns 1-8 of GFF/GTF2/GFF3 files.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_75_get_8_gff_columns(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_74_get_8_gff_columns[] = "SegmentChain._get_8_gff_columns(self, GenomicSegment segment, str feature_type)\nFormat columns 1-8 of GFF/GTF2/GFF3 files.\n        \n        Parameters\n        ----------\n        segment : |GenomicSegment|\n            Segment to export\n        \n        feature_type : str\n            Type of feature (for column 3 of output)\n        \n        \n        Notes\n        ------\n        Columns of GFF files are as follows:\n            ======== =========\n            Column   Contains\n            ======== =========\n                1     Contig or chromosome \n                2     Source of annotation \n                3     Type of feature (\"exon\", \"CDS\", \"start_codon\", \"stop_codon\") \n                4     Start (1-indexed)  \n                5     End (fully-closed)\n                6     Score  \n                7     Strand  \n                8     Frame. Number of bases within feature before first in-frame codon (if CDS) \n                9     Attributes. Formatting depends on flavor of GFF                      \n            ======== =========        \n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_75_get_8_gff_columns(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_segment = 0;
  PyObject *__pyx_v_feature_type = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_8_gff_columns (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_segment,&__pyx_n_s_feature_type,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_segment)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_feature_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_get_8_gff_columns", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2161; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_8_gff_columns") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2161; __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_segment = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)values[0]);
    __pyx_v_feature_type = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_8_gff_columns", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2161; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain._get_8_gff_columns", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_segment), __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment, 1, "segment", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature_type), (&PyString_Type), 1, "feature_type", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_74_get_8_gff_columns(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_segment, __pyx_v_feature_type);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_74_get_8_gff_columns(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_segment, PyObject *__pyx_v_feature_type) {
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_strand = 0;
  PyObject *__pyx_v_phase = 0;
  long __pyx_v_segment_start;
  long __pyx_v_segment_end;
  long __pyx_v_new_segment_start;
  PyObject *__pyx_v_ltmp = 0;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_8_gff_columns", 0);

  /* "plastid/genomics/roitools.pyx":2191
 *         """
 *         cdef:
 *             str chrom  = segment.chrom             # <<<<<<<<<<<<<<
 *             str strand = segment.strand
 *             str phase  = "."
 */
  __pyx_t_1 = __pyx_v_segment->chrom;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_chrom = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2192
 *         cdef:
 *             str chrom  = segment.chrom
 *             str strand = segment.strand             # <<<<<<<<<<<<<<
 *             str phase  = "."
 *             long segment_start = segment.start
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_segment), __pyx_n_s_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_strand = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2193
 *             str chrom  = segment.chrom
 *             str strand = segment.strand
 *             str phase  = "."             # <<<<<<<<<<<<<<
 *             long segment_start = segment.start
 *             long segment_end   = segment.end
 */
  __Pyx_INCREF(__pyx_kp_s__4);
  __pyx_v_phase = __pyx_kp_s__4;

  /* "plastid/genomics/roitools.pyx":2194
 *             str strand = segment.strand
 *             str phase  = "."
 *             long segment_start = segment.start             # <<<<<<<<<<<<<<
 *             long segment_end   = segment.end
 *             long new_segment_start
 */
  __pyx_t_2 = __pyx_v_segment->start;
  __pyx_v_segment_start = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":2195
 *             str phase  = "."
 *             long segment_start = segment.start
 *             long segment_end   = segment.end             # <<<<<<<<<<<<<<
 *             long new_segment_start
 *             list ltmp
 */
  __pyx_t_2 = __pyx_v_segment->end;
  __pyx_v_segment_end = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":2198
 *             long new_segment_start
 *             list ltmp
 *             dict attr = self.attr             # <<<<<<<<<<<<<<
 * 
 *         if feature_type == "CDS":
 */
  __pyx_t_1 = __pyx_v_self->attr;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2200
 *             dict attr = self.attr
 * 
 *         if feature_type == "CDS":             # <<<<<<<<<<<<<<
 *             # use phase/frame if known for length-1 features
 *             # called "phase" in GFF3 conventions; "frame" in GTF2
 */
  __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_v_feature_type, __pyx_n_s_CDS, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":2203
 *             # use phase/frame if known for length-1 features
 *             # called "phase" in GFF3 conventions; "frame" in GTF2
 *             if len(self._segments) == 1 and ("phase" in attr or "frame" in attr):             # <<<<<<<<<<<<<<
 *                 phase = str(attr.get("phase",attr.get("frame")))
 *             # otherwise calculate
 */
    __pyx_t_1 = __pyx_v_self->_segments;
    __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 = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = ((__pyx_t_5 == 1) != 0);
    if (__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L5_bool_binop_done;
    }
    if (unlikely(__pyx_v_attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_phase, __pyx_v_attr, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = (__pyx_t_3 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_4 = __pyx_t_6;
      goto __pyx_L5_bool_binop_done;
    }
    if (unlikely(__pyx_v_attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_frame, __pyx_v_attr, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = (__pyx_t_6 != 0);
    __pyx_t_4 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_4) {

      /* "plastid/genomics/roitools.pyx":2204
 *             # called "phase" in GFF3 conventions; "frame" in GTF2
 *             if len(self._segments) == 1 and ("phase" in attr or "frame" in attr):
 *                 phase = str(attr.get("phase",attr.get("frame")))             # <<<<<<<<<<<<<<
 *             # otherwise calculate
 *             else:
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_attr, __pyx_n_s_frame, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_PyDict_GetItemDefault(__pyx_v_attr, __pyx_n_s_phase, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __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 = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(PyString_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF_SET(__pyx_v_phase, ((PyObject*)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "plastid/genomics/roitools.pyx":2203
 *             # use phase/frame if known for length-1 features
 *             # called "phase" in GFF3 conventions; "frame" in GTF2
 *             if len(self._segments) == 1 and ("phase" in attr or "frame" in attr):             # <<<<<<<<<<<<<<
 *                 phase = str(attr.get("phase",attr.get("frame")))
 *             # otherwise calculate
 */
      goto __pyx_L4;
    }

    /* "plastid/genomics/roitools.pyx":2207
 *             # otherwise calculate
 *             else:
 *                 new_segment_start = self.get_segmentchain_coordinate(chrom,segment_start,strand,stranded=False)             # <<<<<<<<<<<<<<
 *                 phase = str((3 - (new_segment_start % 3)) % 3)
 * 
 */
    /*else*/ {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_segmentchain_coordinate); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_segment_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_chrom);
      __Pyx_GIVEREF(__pyx_v_chrom);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_chrom);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
      __Pyx_INCREF(__pyx_v_strand);
      __Pyx_GIVEREF(__pyx_v_strand);
      PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_strand);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_stranded, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_2 = __Pyx_PyInt_As_long(__pyx_t_9); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_new_segment_start = __pyx_t_2;

      /* "plastid/genomics/roitools.pyx":2208
 *             else:
 *                 new_segment_start = self.get_segmentchain_coordinate(chrom,segment_start,strand,stranded=False)
 *                 phase = str((3 - (new_segment_start % 3)) % 3)             # <<<<<<<<<<<<<<
 * 
 *         ltmp = [chrom,
 */
      __pyx_t_9 = __Pyx_PyInt_From_long(__Pyx_mod_long((3 - __Pyx_mod_long(__pyx_v_new_segment_start, 3)), 3)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(PyString_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_9)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF_SET(__pyx_v_phase, ((PyObject*)__pyx_t_9));
      __pyx_t_9 = 0;
    }
    __pyx_L4:;

    /* "plastid/genomics/roitools.pyx":2200
 *             dict attr = self.attr
 * 
 *         if feature_type == "CDS":             # <<<<<<<<<<<<<<
 *             # use phase/frame if known for length-1 features
 *             # called "phase" in GFF3 conventions; "frame" in GTF2
 */
  }

  /* "plastid/genomics/roitools.pyx":2211
 * 
 *         ltmp = [chrom,
 *                 self.attr.get("source","."),             # <<<<<<<<<<<<<<
 *                 feature_type,
 *                 str(segment_start + 1),
 */
  if (unlikely(__pyx_v_self->attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_9 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_source, __pyx_kp_s__4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);

  /* "plastid/genomics/roitools.pyx":2213
 *                 self.attr.get("source","."),
 *                 feature_type,
 *                 str(segment_start + 1),             # <<<<<<<<<<<<<<
 *                 str(segment_end),
 *                 str(self.attr.get("score",".")),
 */
  __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_segment_start + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "plastid/genomics/roitools.pyx":2214
 *                 feature_type,
 *                 str(segment_start + 1),
 *                 str(segment_end),             # <<<<<<<<<<<<<<
 *                 str(self.attr.get("score",".")),
 *                 strand,
 */
  __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_segment_end); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "plastid/genomics/roitools.pyx":2215
 *                 str(segment_start + 1),
 *                 str(segment_end),
 *                 str(self.attr.get("score",".")),             # <<<<<<<<<<<<<<
 *                 strand,
 *                 phase]
 */
  if (unlikely(__pyx_v_self->attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_score, __pyx_kp_s__4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "plastid/genomics/roitools.pyx":2210
 *                 phase = str((3 - (new_segment_start % 3)) % 3)
 * 
 *         ltmp = [chrom,             # <<<<<<<<<<<<<<
 *                 self.attr.get("source","."),
 *                 feature_type,
 */
  __pyx_t_10 = PyList_New(8); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(__pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_v_chrom);
  PyList_SET_ITEM(__pyx_t_10, 0, __pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_t_9);
  PyList_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
  __Pyx_INCREF(__pyx_v_feature_type);
  __Pyx_GIVEREF(__pyx_v_feature_type);
  PyList_SET_ITEM(__pyx_t_10, 2, __pyx_v_feature_type);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_10, 3, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_8);
  PyList_SET_ITEM(__pyx_t_10, 4, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_7);
  PyList_SET_ITEM(__pyx_t_10, 5, __pyx_t_7);
  __Pyx_INCREF(__pyx_v_strand);
  __Pyx_GIVEREF(__pyx_v_strand);
  PyList_SET_ITEM(__pyx_t_10, 6, __pyx_v_strand);
  __Pyx_INCREF(__pyx_v_phase);
  __Pyx_GIVEREF(__pyx_v_phase);
  PyList_SET_ITEM(__pyx_t_10, 7, __pyx_v_phase);
  __pyx_t_9 = 0;
  __pyx_t_1 = 0;
  __pyx_t_8 = 0;
  __pyx_t_7 = 0;
  __pyx_v_ltmp = ((PyObject*)__pyx_t_10);
  __pyx_t_10 = 0;

  /* "plastid/genomics/roitools.pyx":2219
 *                 phase]
 * 
 *         return ltmp             # <<<<<<<<<<<<<<
 * 
 *     # TODO: optimize
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ltmp);
  __pyx_r = __pyx_v_ltmp;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2161
 * 
 *     # TODO: test optimality
 *     def _get_8_gff_columns(self, GenomicSegment segment, str feature_type):             # <<<<<<<<<<<<<<
 *         """Format columns 1-8 of GFF/GTF2/GFF3 files.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain._get_8_gff_columns", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_strand);
  __Pyx_XDECREF(__pyx_v_phase);
  __Pyx_XDECREF(__pyx_v_ltmp);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2222
 * 
 *     # TODO: optimize
 *     def as_bed(self, thickstart=None, thickend=None, as_int=True, color=None, extra_columns=None):             # <<<<<<<<<<<<<<
 *         """Format |SegmentChain| as a string of BED12[+X] output.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_77as_bed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_76as_bed[] = "SegmentChain.as_bed(self, thickstart=None, thickend=None, as_int=True, color=None, extra_columns=None)\nFormat |SegmentChain| as a string of BED12[+X] output.\n        \n        If the |SegmentChain| was imported as a `BED`_ file with extra columns,\n        these will be output in the same order, after the `BED`_ columns.\n\n        Parameters\n        ----------\n        thickstart : int or `None`, optional\n            If not `None`, overrides the genome coordinate that starts thick\n            plotting in genome browser found in `self.attr['thickstart']`\n    \n        thickend : int or None, optional\n            If not None, overrides the genome coordinate that stops\n            thick plotting in genome browser found in `self.attr['thickend']`\n\n        as_int : bool, optional\n            Force `score` to integer (Default: `True`)\n   \n        color : str or None, optional\n            Color represented as RGB hex string.\n            If not none, overrides the color in `self.attr['color']`\n    \n        extra_columns : None or list, optional\n            If `None`, and the |SegmentChain| was imported using the `extra_columns`\n            keyword of :meth:`~plastid.genomics.roitools.SegmentChain.from_bed`,\n            the |SegmentChain| will be exported in BED 12+X format, in which\n            extra columns are in the same order as they were upon import. If no extra columns\n            were present, the |SegmentChain| will be exported a aa BED12 line.\n\n            If a list of attribute names, these attributes will be exported as\n            extra columns in order, overriding whatever happened upon import. \n            If an attribute name is not in the `attr` dict of the |SegmentChain|,\n            it will be exported with the default empty value \"\".\n\n            If an empty list, no extra columns will be exported; the |SegmentChain|\n            will be formatted as a BED12 line.\n\n\n        Returns\n        -------\n        str \n       ""     Line of BED12[+X]-formatted text\n\n\n        Notes\n        -----\n        BED12 columns are as follows:\n            ======== =========\n            Column   Contains\n            ======== =========\n               1     Contig or chromosome\n               2     Start of first block in feature (0-indexed)\n               3     End of last block in feature (half-open)\n               4     Feature name\n               5     Feature score\n               6     Strand\n               7     thickstart (in chromosomal coordinates)\n               8     thickend (in chromosomal coordinates)\n               9     Feature color as RGB tuple\n               10    Number of blocks in feature\n               11    Block lengths\n               12    Block starts, relative to start of first block\n            ======== =========\n\n        For more details\n            See the `UCSC file format faq <http://genome.ucsc.edu/FAQ/FAQformat.html>`_\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_77as_bed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_thickstart = 0;
  PyObject *__pyx_v_thickend = 0;
  PyObject *__pyx_v_as_int = 0;
  PyObject *__pyx_v_color = 0;
  PyObject *__pyx_v_extra_columns = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_bed (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_thickstart,&__pyx_n_s_thickend,&__pyx_n_s_as_int,&__pyx_n_s_color,&__pyx_n_s_extra_columns,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_True);
    values[3] = ((PyObject *)Py_None);
    values[4] = ((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  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 (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_thickstart);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_thickend);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_as_int);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_color);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_extra_columns);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "as_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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;
      }
    }
    __pyx_v_thickstart = values[0];
    __pyx_v_thickend = values[1];
    __pyx_v_as_int = values[2];
    __pyx_v_color = values[3];
    __pyx_v_extra_columns = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("as_bed", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_76as_bed(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_thickstart, __pyx_v_thickend, __pyx_v_as_int, __pyx_v_color, __pyx_v_extra_columns);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_2generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "plastid/genomics/roitools.pyx":2312
 *                 else:
 *                     # is a tuple or sequence
 *                     if all(isinstance(X,float) for X in color) and \             # <<<<<<<<<<<<<<
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):
 */

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *)__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr(__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_2generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_as_bed_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_2generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    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 = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) { __Pyx_RaiseClosureNameError("color"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_color; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_X);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_X, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_5 = PyFloat_Check(__pyx_cur_scope->__pyx_v_X); 
    __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
    if (__pyx_t_6) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_5generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "plastid/genomics/roitools.pyx":2313
 *                     # is a tuple or sequence
 *                     if all(isinstance(X,float) for X in color) and \
 *                        all(X < 1 for X in color) and \             # <<<<<<<<<<<<<<
 *                        all(X > 0 for X in color):
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)
 */

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_3genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *)__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr(__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_5generator1, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_as_bed_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_5generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    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 = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) { __Pyx_RaiseClosureNameError("color"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_color; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_X);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_X, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_X, __pyx_int_1, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = ((!__pyx_t_5) != 0);
    if (__pyx_t_6) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_8generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "plastid/genomics/roitools.pyx":2314
 *                     if all(isinstance(X,float) for X in color) and \
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):             # <<<<<<<<<<<<<<
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)
 *                     else:
 */

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_6genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *)__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr(__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_8generator2, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_as_bed_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_8generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    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 = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) { __Pyx_RaiseClosureNameError("color"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_color; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color); 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_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_X);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_X, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_X, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = ((!__pyx_t_5) != 0);
    if (__pyx_t_6) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_11generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "plastid/genomics/roitools.pyx":2315
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)             # <<<<<<<<<<<<<<
 *                     else:
 *                        color = "%s,%s,%s" % tuple(color)
 */

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_9genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *)__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr(__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_11generator3, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_as_bed_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_11generator3(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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 = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) { __Pyx_RaiseClosureNameError("color"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_color; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_color); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_X);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_X, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Multiply(__pyx_int_255, __pyx_cur_scope->__pyx_v_X); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_round, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __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_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;
    if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2222
 * 
 *     # TODO: optimize
 *     def as_bed(self, thickstart=None, thickend=None, as_int=True, color=None, extra_columns=None):             # <<<<<<<<<<<<<<
 *         """Format |SegmentChain| as a string of BED12[+X] output.
 * 
 */

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_76as_bed(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_thickstart, PyObject *__pyx_v_thickend, PyObject *__pyx_v_as_int, PyObject *__pyx_v_color, PyObject *__pyx_v_extra_columns) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *__pyx_cur_scope;
  PyObject *__pyx_v_ltmp = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_span = 0;
  PyObject *__pyx_v_score = NULL;
  PyObject *__pyx_v_X = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  double __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  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)(PyObject *);
  PyObject *__pyx_t_17 = NULL;
  Py_ssize_t __pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_t_22;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("as_bed", 0);
  __pyx_cur_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed(__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_color = __pyx_v_color;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_color);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_color);
  __Pyx_INCREF(__pyx_v_thickstart);
  __Pyx_INCREF(__pyx_v_thickend);
  __Pyx_INCREF(__pyx_v_extra_columns);

  /* "plastid/genomics/roitools.pyx":2294
 *             GenomicSegment span
 * 
 *         if len(self) > 0:             # <<<<<<<<<<<<<<
 *             score = self.attr.get("score",0)
 *             span = self.spanning_segment
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((__pyx_t_1 > 0) != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":2295
 * 
 *         if len(self) > 0:
 *             score = self.attr.get("score",0)             # <<<<<<<<<<<<<<
 *             span = self.spanning_segment
 *             try:
 */
    if (unlikely(__pyx_v_self->attr == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_score, __pyx_int_0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_score = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":2296
 *         if len(self) > 0:
 *             score = self.attr.get("score",0)
 *             span = self.spanning_segment             # <<<<<<<<<<<<<<
 *             try:
 *                 score = float(score)
 */
    __pyx_t_3 = ((PyObject *)__pyx_v_self->spanning_segment);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_span = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":2297
 *             score = self.attr.get("score",0)
 *             span = self.spanning_segment
 *             try:             # <<<<<<<<<<<<<<
 *                 score = float(score)
 *                 if as_int is True:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      /*try:*/ {

        /* "plastid/genomics/roitools.pyx":2298
 *             span = self.spanning_segment
 *             try:
 *                 score = float(score)             # <<<<<<<<<<<<<<
 *                 if as_int is True:
 *                     score = int(round(score))
 */
        __pyx_t_7 = __Pyx_PyObject_AsDouble(__pyx_v_score); if (unlikely(__pyx_t_7 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __pyx_t_3 = PyFloat_FromDouble(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF_SET(__pyx_v_score, __pyx_t_3);
        __pyx_t_3 = 0;

        /* "plastid/genomics/roitools.pyx":2299
 *             try:
 *                 score = float(score)
 *                 if as_int is True:             # <<<<<<<<<<<<<<
 *                     score = int(round(score))
 *             except ValueError:
 */
        __pyx_t_2 = (__pyx_v_as_int == Py_True);
        __pyx_t_8 = (__pyx_t_2 != 0);
        if (__pyx_t_8) {

          /* "plastid/genomics/roitools.pyx":2300
 *                 score = float(score)
 *                 if as_int is True:
 *                     score = int(round(score))             # <<<<<<<<<<<<<<
 *             except ValueError:
 *                 score = 0
 */
          __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_INCREF(__pyx_v_score);
          __Pyx_GIVEREF(__pyx_v_score);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_score);
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_round, __pyx_t_3, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyNumber_Int(__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF_SET(__pyx_v_score, __pyx_t_3);
          __pyx_t_3 = 0;

          /* "plastid/genomics/roitools.pyx":2299
 *             try:
 *                 score = float(score)
 *                 if as_int is True:             # <<<<<<<<<<<<<<
 *                     score = int(round(score))
 *             except ValueError:
 */
        }

        /* "plastid/genomics/roitools.pyx":2297
 *             score = self.attr.get("score",0)
 *             span = self.spanning_segment
 *             try:             # <<<<<<<<<<<<<<
 *                 score = float(score)
 *                 if as_int is True:
 */
      }
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "plastid/genomics/roitools.pyx":2301
 *                 if as_int is True:
 *                     score = int(round(score))
 *             except ValueError:             # <<<<<<<<<<<<<<
 *                 score = 0
 *             except TypeError:
 */
      __pyx_t_10 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_t_10) {
        __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_11);

        /* "plastid/genomics/roitools.pyx":2302
 *                     score = int(round(score))
 *             except ValueError:
 *                 score = 0             # <<<<<<<<<<<<<<
 *             except TypeError:
 *                 score = 0
 */
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_DECREF_SET(__pyx_v_score, __pyx_int_0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L5_exception_handled;
      }

      /* "plastid/genomics/roitools.pyx":2303
 *             except ValueError:
 *                 score = 0
 *             except TypeError:             # <<<<<<<<<<<<<<
 *                 score = 0
 * 
 */
      __pyx_t_10 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_10) {
        __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_9, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2303; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_3);

        /* "plastid/genomics/roitools.pyx":2304
 *                 score = 0
 *             except TypeError:
 *                 score = 0             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_DECREF_SET(__pyx_v_score, __pyx_int_0);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L5_exception_handled;
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "plastid/genomics/roitools.pyx":2297
 *             score = self.attr.get("score",0)
 *             span = self.spanning_segment
 *             try:             # <<<<<<<<<<<<<<
 *                 score = float(score)
 *                 if as_int is True:
 */
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
      __pyx_L11_try_end:;
    }

    /* "plastid/genomics/roitools.pyx":2306
 *                 score = 0
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 color = self.attr.get("color","#000000")
 *                 if isinstance(color,str):
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_4);
      /*try:*/ {

        /* "plastid/genomics/roitools.pyx":2307
 * 
 *             try:
 *                 color = self.attr.get("color","#000000")             # <<<<<<<<<<<<<<
 *                 if isinstance(color,str):
 *                     color = "%s,%s,%s" % tuple(get_rgb255(color))
 */
        if (unlikely(__pyx_v_self->attr == Py_None)) {
          PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
        }
        __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_color, __pyx_kp_s_000000); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_color);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_color, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;

        /* "plastid/genomics/roitools.pyx":2308
 *             try:
 *                 color = self.attr.get("color","#000000")
 *                 if isinstance(color,str):             # <<<<<<<<<<<<<<
 *                     color = "%s,%s,%s" % tuple(get_rgb255(color))
 *                 else:
 */
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_color;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_8 = PyString_Check(__pyx_t_3); 
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_2 = (__pyx_t_8 != 0);
        if (__pyx_t_2) {

          /* "plastid/genomics/roitools.pyx":2309
 *                 color = self.attr.get("color","#000000")
 *                 if isinstance(color,str):
 *                     color = "%s,%s,%s" % tuple(get_rgb255(color))             # <<<<<<<<<<<<<<
 *                 else:
 *                     # is a tuple or sequence
 */
          __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_rgb255); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_11 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
            if (likely(__pyx_t_11)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_11);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_9, function);
            }
          }
          if (!__pyx_t_11) {
            __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_cur_scope->__pyx_v_color); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            __Pyx_GOTREF(__pyx_t_3);
          } else {
            __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_color);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_color);
            PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_cur_scope->__pyx_v_color);
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_3, __pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_color);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_color, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;

          /* "plastid/genomics/roitools.pyx":2308
 *             try:
 *                 color = self.attr.get("color","#000000")
 *                 if isinstance(color,str):             # <<<<<<<<<<<<<<
 *                     color = "%s,%s,%s" % tuple(get_rgb255(color))
 *                 else:
 */
          goto __pyx_L25;
        }

        /* "plastid/genomics/roitools.pyx":2312
 *                 else:
 *                     # is a tuple or sequence
 *                     if all(isinstance(X,float) for X in color) and \             # <<<<<<<<<<<<<<
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):
 */
        /*else*/ {
          __pyx_t_3 = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_9 = __Pyx_Generator_Next(__pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (__pyx_t_8) {
          } else {
            __pyx_t_2 = __pyx_t_8;
            goto __pyx_L27_bool_binop_done;
          }

          /* "plastid/genomics/roitools.pyx":2313
 *                     # is a tuple or sequence
 *                     if all(isinstance(X,float) for X in color) and \
 *                        all(X < 1 for X in color) and \             # <<<<<<<<<<<<<<
 *                        all(X > 0 for X in color):
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)
 */
          __pyx_t_9 = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_3genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_3 = __Pyx_Generator_Next(__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (__pyx_t_8) {
          } else {
            __pyx_t_2 = __pyx_t_8;
            goto __pyx_L27_bool_binop_done;
          }

          /* "plastid/genomics/roitools.pyx":2314
 *                     if all(isinstance(X,float) for X in color) and \
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):             # <<<<<<<<<<<<<<
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)
 *                     else:
 */
          __pyx_t_3 = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_6genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_9 = __Pyx_Generator_Next(__pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_2 = __pyx_t_8;
          __pyx_L27_bool_binop_done:;

          /* "plastid/genomics/roitools.pyx":2312
 *                 else:
 *                     # is a tuple or sequence
 *                     if all(isinstance(X,float) for X in color) and \             # <<<<<<<<<<<<<<
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):
 */
          if (__pyx_t_2) {

            /* "plastid/genomics/roitools.pyx":2315
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)             # <<<<<<<<<<<<<<
 *                     else:
 *                        color = "%s,%s,%s" % tuple(color)
 */
            __pyx_t_9 = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_bed_9genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_3, __pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_color);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_color, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            __pyx_t_3 = 0;

            /* "plastid/genomics/roitools.pyx":2312
 *                 else:
 *                     # is a tuple or sequence
 *                     if all(isinstance(X,float) for X in color) and \             # <<<<<<<<<<<<<<
 *                        all(X < 1 for X in color) and \
 *                        all(X > 0 for X in color):
 */
            goto __pyx_L26;
          }

          /* "plastid/genomics/roitools.pyx":2317
 *                        color = "%s,%s,%s" % (int(round(255*X)) for X in color)
 *                     else:
 *                        color = "%s,%s,%s" % tuple(color)             # <<<<<<<<<<<<<<
 * 
 *             except ValueError:
 */
          /*else*/ {
            __pyx_t_3 = PySequence_Tuple(__pyx_cur_scope->__pyx_v_color); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_3, __pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_color);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_color, __pyx_t_9);
            __Pyx_GIVEREF(__pyx_t_9);
            __pyx_t_9 = 0;
          }
          __pyx_L26:;
        }
        __pyx_L25:;

        /* "plastid/genomics/roitools.pyx":2306
 *                 score = 0
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 color = self.attr.get("color","#000000")
 *                 if isinstance(color,str):
 */
      }
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L24_try_end;
      __pyx_L17_error:;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "plastid/genomics/roitools.pyx":2319
 *                        color = "%s,%s,%s" % tuple(color)
 * 
 *             except ValueError:             # <<<<<<<<<<<<<<
 *                 color = self.attr.get("color","0,0,0") if color is None else color
 * 
 */
      __pyx_t_10 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
      if (__pyx_t_10) {
        __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_3, &__pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2319; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_12);

        /* "plastid/genomics/roitools.pyx":2320
 * 
 *             except ValueError:
 *                 color = self.attr.get("color","0,0,0") if color is None else color             # <<<<<<<<<<<<<<
 * 
 *             thickstart = self.attr.get("thickstart",span.start) if thickstart is None else thickstart
 */
        __pyx_t_2 = (__pyx_cur_scope->__pyx_v_color == Py_None);
        if ((__pyx_t_2 != 0)) {
          if (unlikely(__pyx_v_self->attr == Py_None)) {
            PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
          }
          __pyx_t_13 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_color, __pyx_kp_s_0_0_0); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_11 = __pyx_t_13;
          __pyx_t_13 = 0;
        } else {
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_color);
          __pyx_t_11 = __pyx_cur_scope->__pyx_v_color;
        }
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_color);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_color, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L18_exception_handled;
      }
      goto __pyx_L19_except_error;
      __pyx_L19_except_error:;

      /* "plastid/genomics/roitools.pyx":2306
 *                 score = 0
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 color = self.attr.get("color","#000000")
 *                 if isinstance(color,str):
 */
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4);
      goto __pyx_L1_error;
      __pyx_L18_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4);
      __pyx_L24_try_end:;
    }

    /* "plastid/genomics/roitools.pyx":2322
 *                 color = self.attr.get("color","0,0,0") if color is None else color
 * 
 *             thickstart = self.attr.get("thickstart",span.start) if thickstart is None else thickstart             # <<<<<<<<<<<<<<
 *             thickend   = self.attr.get("thickend",span.start)   if thickend   is None else thickend
 * 
 */
    __pyx_t_2 = (__pyx_v_thickstart == Py_None);
    if ((__pyx_t_2 != 0)) {
      if (unlikely(__pyx_v_self->attr == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_span->start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_thickstart, __pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_12 = __pyx_t_9;
      __pyx_t_9 = 0;
    } else {
      __Pyx_INCREF(__pyx_v_thickstart);
      __pyx_t_12 = __pyx_v_thickstart;
    }
    __Pyx_DECREF_SET(__pyx_v_thickstart, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "plastid/genomics/roitools.pyx":2323
 * 
 *             thickstart = self.attr.get("thickstart",span.start) if thickstart is None else thickstart
 *             thickend   = self.attr.get("thickend",span.start)   if thickend   is None else thickend             # <<<<<<<<<<<<<<
 * 
 *             ltmp = [span.chrom,
 */
    __pyx_t_2 = (__pyx_v_thickend == Py_None);
    if ((__pyx_t_2 != 0)) {
      if (unlikely(__pyx_v_self->attr == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_v_span->start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_thickend, __pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_12 = __pyx_t_3;
      __pyx_t_3 = 0;
    } else {
      __Pyx_INCREF(__pyx_v_thickend);
      __pyx_t_12 = __pyx_v_thickend;
    }
    __Pyx_DECREF_SET(__pyx_v_thickend, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "plastid/genomics/roitools.pyx":2326
 * 
 *             ltmp = [span.chrom,
 *                     span.start,             # <<<<<<<<<<<<<<
 *                     span.end,
 *                     self.get_name(),
 */
    __pyx_t_12 = __Pyx_PyInt_From_long(__pyx_v_span->start); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);

    /* "plastid/genomics/roitools.pyx":2327
 *             ltmp = [span.chrom,
 *                     span.start,
 *                     span.end,             # <<<<<<<<<<<<<<
 *                     self.get_name(),
 *                     score,
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_span->end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);

    /* "plastid/genomics/roitools.pyx":2328
 *                     span.start,
 *                     span.end,
 *                     self.get_name(),             # <<<<<<<<<<<<<<
 *                     score,
 *                     span.strand,
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_13 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (__pyx_t_13) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_13); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    } else {
      __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "plastid/genomics/roitools.pyx":2330
 *                     self.get_name(),
 *                     score,
 *                     span.strand,             # <<<<<<<<<<<<<<
 *                     thickstart,
 *                     thickend,
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_span), __pyx_n_s_strand); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);

    /* "plastid/genomics/roitools.pyx":2334
 *                     thickend,
 *                     color,
 *                     len(self),             # <<<<<<<<<<<<<<
 *                     ",".join([str(len(X)) for X in self]) + ",",
 *                     ",".join([str(X.start - self[0].start) for X in self]) + ","
 */
    __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_13 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);

    /* "plastid/genomics/roitools.pyx":2335
 *                     color,
 *                     len(self),
 *                     ",".join([str(len(X)) for X in self]) + ",",             # <<<<<<<<<<<<<<
 *                     ",".join([str(X.start - self[0].start) for X in self]) + ","
 *                    ]
 */
    __pyx_t_14 = PyList_New(0); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
      __pyx_t_15 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_15); __pyx_t_1 = 0;
      __pyx_t_16 = NULL;
    } else {
      __pyx_t_1 = -1; __pyx_t_15 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = Py_TYPE(__pyx_t_15)->tp_iternext; if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_16)) {
        if (likely(PyList_CheckExact(__pyx_t_15))) {
          if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_15)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_17 = PyList_GET_ITEM(__pyx_t_15, __pyx_t_1); __Pyx_INCREF(__pyx_t_17); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_17 = PySequence_ITEM(__pyx_t_15, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          #endif
        } else {
          if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_15)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_17 = PyTuple_GET_ITEM(__pyx_t_15, __pyx_t_1); __Pyx_INCREF(__pyx_t_17); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_17 = PySequence_ITEM(__pyx_t_15, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          #endif
        }
      } else {
        __pyx_t_17 = __pyx_t_16(__pyx_t_15);
        if (unlikely(!__pyx_t_17)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_17);
      }
      __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_17);
      __pyx_t_17 = 0;
      __pyx_t_18 = PyObject_Length(__pyx_v_X); if (unlikely(__pyx_t_18 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_17 = PyInt_FromSsize_t(__pyx_t_18); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_17);
      __pyx_t_17 = 0;
      __pyx_t_17 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_19, NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_14, (PyObject*)__pyx_t_17))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_t_14); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = PyNumber_Add(__pyx_t_15, __pyx_kp_s_); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

    /* "plastid/genomics/roitools.pyx":2336
 *                     len(self),
 *                     ",".join([str(len(X)) for X in self]) + ",",
 *                     ",".join([str(X.start - self[0].start) for X in self]) + ","             # <<<<<<<<<<<<<<
 *                    ]
 * 
 */
    __pyx_t_15 = PyList_New(0); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
      __pyx_t_17 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_17); __pyx_t_1 = 0;
      __pyx_t_16 = NULL;
    } else {
      __pyx_t_1 = -1; __pyx_t_17 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_16 = Py_TYPE(__pyx_t_17)->tp_iternext; if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_16)) {
        if (likely(PyList_CheckExact(__pyx_t_17))) {
          if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_17)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_19 = PyList_GET_ITEM(__pyx_t_17, __pyx_t_1); __Pyx_INCREF(__pyx_t_19); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_19 = PySequence_ITEM(__pyx_t_17, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          #endif
        } else {
          if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_17)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_19 = PyTuple_GET_ITEM(__pyx_t_17, __pyx_t_1); __Pyx_INCREF(__pyx_t_19); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_19 = PySequence_ITEM(__pyx_t_17, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_19);
          #endif
        }
      } else {
        __pyx_t_19 = __pyx_t_16(__pyx_t_17);
        if (unlikely(!__pyx_t_19)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_19);
      }
      __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_19);
      __pyx_t_19 = 0;
      __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_start); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_20 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_20 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_20);
      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_start); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __pyx_t_20 = PyNumber_Subtract(__pyx_t_19, __pyx_t_21); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_21 = PyTuple_New(1); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_GIVEREF(__pyx_t_20);
      PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_20);
      __pyx_t_20 = 0;
      __pyx_t_20 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_21, NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_15, (PyObject*)__pyx_t_20))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    }
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_17 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_t_15); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = PyNumber_Add(__pyx_t_17, __pyx_kp_s_); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

    /* "plastid/genomics/roitools.pyx":2325
 *             thickend   = self.attr.get("thickend",span.start)   if thickend   is None else thickend
 * 
 *             ltmp = [span.chrom,             # <<<<<<<<<<<<<<
 *                     span.start,
 *                     span.end,
 */
    __pyx_t_17 = PyList_New(12); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_INCREF(__pyx_v_span->chrom);
    __Pyx_GIVEREF(__pyx_v_span->chrom);
    PyList_SET_ITEM(__pyx_t_17, 0, __pyx_v_span->chrom);
    __Pyx_GIVEREF(__pyx_t_12);
    PyList_SET_ITEM(__pyx_t_17, 1, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_17, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_9);
    PyList_SET_ITEM(__pyx_t_17, 3, __pyx_t_9);
    __Pyx_INCREF(__pyx_v_score);
    __Pyx_GIVEREF(__pyx_v_score);
    PyList_SET_ITEM(__pyx_t_17, 4, __pyx_v_score);
    __Pyx_GIVEREF(__pyx_t_11);
    PyList_SET_ITEM(__pyx_t_17, 5, __pyx_t_11);
    __Pyx_INCREF(__pyx_v_thickstart);
    __Pyx_GIVEREF(__pyx_v_thickstart);
    PyList_SET_ITEM(__pyx_t_17, 6, __pyx_v_thickstart);
    __Pyx_INCREF(__pyx_v_thickend);
    __Pyx_GIVEREF(__pyx_v_thickend);
    PyList_SET_ITEM(__pyx_t_17, 7, __pyx_v_thickend);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_color);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_color);
    PyList_SET_ITEM(__pyx_t_17, 8, __pyx_cur_scope->__pyx_v_color);
    __Pyx_GIVEREF(__pyx_t_13);
    PyList_SET_ITEM(__pyx_t_17, 9, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_14);
    PyList_SET_ITEM(__pyx_t_17, 10, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_15);
    PyList_SET_ITEM(__pyx_t_17, 11, __pyx_t_15);
    __pyx_t_12 = 0;
    __pyx_t_3 = 0;
    __pyx_t_9 = 0;
    __pyx_t_11 = 0;
    __pyx_t_13 = 0;
    __pyx_t_14 = 0;
    __pyx_t_15 = 0;
    __pyx_v_ltmp = ((PyObject*)__pyx_t_17);
    __pyx_t_17 = 0;

    /* "plastid/genomics/roitools.pyx":2339
 *                    ]
 * 
 *             if extra_columns is None:             # <<<<<<<<<<<<<<
 *                 extra_columns = self.attr.get("_bedx_column_order",[])
 * 
 */
    __pyx_t_2 = (__pyx_v_extra_columns == Py_None);
    __pyx_t_8 = (__pyx_t_2 != 0);
    if (__pyx_t_8) {

      /* "plastid/genomics/roitools.pyx":2340
 * 
 *             if extra_columns is None:
 *                 extra_columns = self.attr.get("_bedx_column_order",[])             # <<<<<<<<<<<<<<
 * 
 *             if len(extra_columns) > 0:
 */
      if (unlikely(__pyx_v_self->attr == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_17 = PyList_New(0); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_15 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_n_s_bedx_column_order, __pyx_t_17); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_DECREF_SET(__pyx_v_extra_columns, __pyx_t_15);
      __pyx_t_15 = 0;

      /* "plastid/genomics/roitools.pyx":2339
 *                    ]
 * 
 *             if extra_columns is None:             # <<<<<<<<<<<<<<
 *                 extra_columns = self.attr.get("_bedx_column_order",[])
 * 
 */
    }

    /* "plastid/genomics/roitools.pyx":2342
 *                 extra_columns = self.attr.get("_bedx_column_order",[])
 * 
 *             if len(extra_columns) > 0:             # <<<<<<<<<<<<<<
 *                 ltmp.extend([self.attr.get(X,"") for X in extra_columns])
 * 
 */
    __pyx_t_1 = PyObject_Length(__pyx_v_extra_columns); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = ((__pyx_t_1 > 0) != 0);
    if (__pyx_t_8) {

      /* "plastid/genomics/roitools.pyx":2343
 * 
 *             if len(extra_columns) > 0:
 *                 ltmp.extend([self.attr.get(X,"") for X in extra_columns])             # <<<<<<<<<<<<<<
 * 
 *             return "\t".join([str(X) for X in ltmp]) + "\n"
 */
      __pyx_t_15 = PyList_New(0); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      if (likely(PyList_CheckExact(__pyx_v_extra_columns)) || PyTuple_CheckExact(__pyx_v_extra_columns)) {
        __pyx_t_17 = __pyx_v_extra_columns; __Pyx_INCREF(__pyx_t_17); __pyx_t_1 = 0;
        __pyx_t_16 = NULL;
      } else {
        __pyx_t_1 = -1; __pyx_t_17 = PyObject_GetIter(__pyx_v_extra_columns); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_16 = Py_TYPE(__pyx_t_17)->tp_iternext; if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      for (;;) {
        if (likely(!__pyx_t_16)) {
          if (likely(PyList_CheckExact(__pyx_t_17))) {
            if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_17)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_14 = PyList_GET_ITEM(__pyx_t_17, __pyx_t_1); __Pyx_INCREF(__pyx_t_14); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_14 = PySequence_ITEM(__pyx_t_17, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_14);
            #endif
          } else {
            if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_17)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_17, __pyx_t_1); __Pyx_INCREF(__pyx_t_14); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_14 = PySequence_ITEM(__pyx_t_17, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_14);
            #endif
          }
        } else {
          __pyx_t_14 = __pyx_t_16(__pyx_t_17);
          if (unlikely(!__pyx_t_14)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_14);
        }
        __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_14);
        __pyx_t_14 = 0;
        if (unlikely(__pyx_v_self->attr == Py_None)) {
          PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_14 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->attr, __pyx_v_X, __pyx_kp_s__16); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_15, (PyObject*)__pyx_t_14))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_22 = __Pyx_PyList_Extend(__pyx_v_ltmp, __pyx_t_15); if (unlikely(__pyx_t_22 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

      /* "plastid/genomics/roitools.pyx":2342
 *                 extra_columns = self.attr.get("_bedx_column_order",[])
 * 
 *             if len(extra_columns) > 0:             # <<<<<<<<<<<<<<
 *                 ltmp.extend([self.attr.get(X,"") for X in extra_columns])
 * 
 */
    }

    /* "plastid/genomics/roitools.pyx":2345
 *                 ltmp.extend([self.attr.get(X,"") for X in extra_columns])
 * 
 *             return "\t".join([str(X) for X in ltmp]) + "\n"             # <<<<<<<<<<<<<<
 *         else:
 *             # SegmentChain with no intervals
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_15 = PyList_New(0); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_17 = __pyx_v_ltmp; __Pyx_INCREF(__pyx_t_17); __pyx_t_1 = 0;
    for (;;) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_17)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_14 = PyList_GET_ITEM(__pyx_t_17, __pyx_t_1); __Pyx_INCREF(__pyx_t_14); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_14 = PySequence_ITEM(__pyx_t_17, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_14);
      __pyx_t_14 = 0;
      __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_INCREF(__pyx_v_X);
      __Pyx_GIVEREF(__pyx_v_X);
      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_v_X);
      __pyx_t_13 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_14, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_15, (PyObject*)__pyx_t_13))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_17 = __Pyx_PyString_Join(__pyx_kp_s__17, __pyx_t_15); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = PyNumber_Add(__pyx_t_17, __pyx_kp_s__18); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_r = __pyx_t_15;
    __pyx_t_15 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":2294
 *             GenomicSegment span
 * 
 *         if len(self) > 0:             # <<<<<<<<<<<<<<
 *             score = self.attr.get("score",0)
 *             span = self.spanning_segment
 */
  }

  /* "plastid/genomics/roitools.pyx":2348
 *         else:
 *             # SegmentChain with no intervals
 *             return ""             # <<<<<<<<<<<<<<
 * 
 *     def as_psl(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__16);
    __pyx_r = __pyx_kp_s__16;
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":2222
 * 
 *     # TODO: optimize
 *     def as_bed(self, thickstart=None, thickend=None, as_int=True, color=None, extra_columns=None):             # <<<<<<<<<<<<<<
 *         """Format |SegmentChain| as a string of BED12[+X] output.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __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_17);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ltmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_span);
  __Pyx_XDECREF(__pyx_v_score);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XDECREF(__pyx_v_thickstart);
  __Pyx_XDECREF(__pyx_v_thickend);
  __Pyx_XDECREF(__pyx_v_extra_columns);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2350
 *             return ""
 * 
 *     def as_psl(self):             # <<<<<<<<<<<<<<
 *         """Formats |SegmentChain| as `PSL`_ (blat) output.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_79as_psl(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_78as_psl[] = "SegmentChain.as_psl(self)\nFormats |SegmentChain| as `PSL`_ (blat) output.\n        \n        Notes\n        -----\n        This will raise an :py:class:`AttributeError` unless the following\n        keys are present and defined in `self.attr`, corresponding to the\n        columns of a `PSL`_ file:\n        \n            ======  ===================================\n            Column  Key\n            ======  ===================================\n                1   ``match_length``\n                2   ``mismatches``\n                3   ``rep_matches``\n                4   ``N``\n                5   ``query_gap_count``\n                6   ``query_gap_bases``\n                7   ``target_gap_count``\n                8   ``target_gap_bases``\n                9   ``strand``\n                10  ``query_name``\n                11  ``query_length``\n                12  ``query_start``\n                13  ``query_end``\n                14  ``target_name``\n                15  ``target_length``\n                16  ``target_start``\n                17  ``target_end``\n                19  ``q_starts`` : list of integers\n                20  ``l_starts`` : list of integers\n            ======  ===================================\n        \n        These keys are defined only if the |SegmentChain| was created by\n        :py:meth:`SegmentChain.from_psl`, or if the user has defined them.\n        \n        See the `PSL spec <http://pombe.nci.nih.gov/genome/goldenPath/help/blatSpec.html>`_\n        for more information.\n        \n        \n        Returns\n        -------\n        str\n            PSL-representation of BLAT alignment\n\n        \n        Raises\n        ------\n        AttributeError\n            If not all of the attributes listed above are defined\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_79as_psl(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_psl (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_78as_psl(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_psl_2generator4(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "plastid/genomics/roitools.pyx":2434
 *             ltmp.append(q_starts)
 *             ltmp.append(t_starts)
 *             return "\t".join(str(X) for X in ltmp) + "\n"             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise AttributeError("SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end")
 */

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_psl_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *)__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr(__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_psl_2generator4, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_as_psl_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_psl.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_7plastid_8genomics_8roitools_12SegmentChain_6as_psl_2generator4(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *__pyx_cur_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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 = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_ltmp)) { __Pyx_RaiseClosureNameError("ltmp"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_ltmp == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_ltmp; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __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[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_X);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_X, __pyx_t_3);
    __Pyx_GIVEREF(__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 = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_X);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_X);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_X);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __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;
    if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2350
 *             return ""
 * 
 *     def as_psl(self):             # <<<<<<<<<<<<<<
 *         """Formats |SegmentChain| as `PSL`_ (blat) output.
 * 
 */

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_78as_psl(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *__pyx_cur_scope;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_v_block_sizes = 0;
  PyObject *__pyx_v_q_starts = 0;
  PyObject *__pyx_v_t_starts = 0;
  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;
  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;
  Py_ssize_t __pyx_t_21;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *(*__pyx_t_24)(PyObject *);
  Py_ssize_t __pyx_t_25;
  int __pyx_t_26;
  int __pyx_t_27;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("as_psl", 0);
  __pyx_cur_scope = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *)__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl(__pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);

  /* "plastid/genomics/roitools.pyx":2402
 *         """
 *         cdef:
 *             dict attr = self.attr             # <<<<<<<<<<<<<<
 *             list ltmp
 *             str block_sizes, q_starts, t_starts
 */
  __pyx_t_1 = __pyx_v_self->attr;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2405
 *             list ltmp
 *             str block_sizes, q_starts, t_starts
 *         try:             # <<<<<<<<<<<<<<
 *             ltmp = [
 *                 attr["match_length"],
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    /*try:*/ {

      /* "plastid/genomics/roitools.pyx":2407
 *         try:
 *             ltmp = [
 *                 attr["match_length"],             # <<<<<<<<<<<<<<
 *                 attr["mismatches"],
 *                 attr["rep_matches"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2407; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_match_length); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2407; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_1);

      /* "plastid/genomics/roitools.pyx":2408
 *             ltmp = [
 *                 attr["match_length"],
 *                 attr["mismatches"],             # <<<<<<<<<<<<<<
 *                 attr["rep_matches"],
 *                 attr["N"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2408; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_mismatches); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2408; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_5);

      /* "plastid/genomics/roitools.pyx":2409
 *                 attr["match_length"],
 *                 attr["mismatches"],
 *                 attr["rep_matches"],             # <<<<<<<<<<<<<<
 *                 attr["N"],
 *                 attr["query_gap_count"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2409; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_rep_matches); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2409; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_6);

      /* "plastid/genomics/roitools.pyx":2410
 *                 attr["mismatches"],
 *                 attr["rep_matches"],
 *                 attr["N"],             # <<<<<<<<<<<<<<
 *                 attr["query_gap_count"],
 *                 attr["query_gap_bases"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_N); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2410; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_7);

      /* "plastid/genomics/roitools.pyx":2411
 *                 attr["rep_matches"],
 *                 attr["N"],
 *                 attr["query_gap_count"],             # <<<<<<<<<<<<<<
 *                 attr["query_gap_bases"],
 *                 attr["target_gap_count"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2411; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_8 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_query_gap_count); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2411; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_8);

      /* "plastid/genomics/roitools.pyx":2412
 *                 attr["N"],
 *                 attr["query_gap_count"],
 *                 attr["query_gap_bases"],             # <<<<<<<<<<<<<<
 *                 attr["target_gap_count"],
 *                 attr["target_gap_bases"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_query_gap_bases); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2412; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_9);

      /* "plastid/genomics/roitools.pyx":2413
 *                 attr["query_gap_count"],
 *                 attr["query_gap_bases"],
 *                 attr["target_gap_count"],             # <<<<<<<<<<<<<<
 *                 attr["target_gap_bases"],
 *                 attr["strand"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2413; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_10 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_target_gap_count); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2413; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_10);

      /* "plastid/genomics/roitools.pyx":2414
 *                 attr["query_gap_bases"],
 *                 attr["target_gap_count"],
 *                 attr["target_gap_bases"],             # <<<<<<<<<<<<<<
 *                 attr["strand"],
 *                 attr["query_name"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_target_gap_bases); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_11);

      /* "plastid/genomics/roitools.pyx":2415
 *                 attr["target_gap_count"],
 *                 attr["target_gap_bases"],
 *                 attr["strand"],             # <<<<<<<<<<<<<<
 *                 attr["query_name"],
 *                 attr["query_length"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_12 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_strand); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2415; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_12);

      /* "plastid/genomics/roitools.pyx":2416
 *                 attr["target_gap_bases"],
 *                 attr["strand"],
 *                 attr["query_name"],             # <<<<<<<<<<<<<<
 *                 attr["query_length"],
 *                 attr["query_start"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2416; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_13 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_query_name); if (unlikely(__pyx_t_13 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2416; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_13);

      /* "plastid/genomics/roitools.pyx":2417
 *                 attr["strand"],
 *                 attr["query_name"],
 *                 attr["query_length"],             # <<<<<<<<<<<<<<
 *                 attr["query_start"],
 *                 attr["query_end"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_14 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_query_length); if (unlikely(__pyx_t_14 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_14);

      /* "plastid/genomics/roitools.pyx":2418
 *                 attr["query_name"],
 *                 attr["query_length"],
 *                 attr["query_start"],             # <<<<<<<<<<<<<<
 *                 attr["query_end"],
 *                 attr["target_name"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2418; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_15 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_query_start); if (unlikely(__pyx_t_15 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2418; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_15);

      /* "plastid/genomics/roitools.pyx":2419
 *                 attr["query_length"],
 *                 attr["query_start"],
 *                 attr["query_end"],             # <<<<<<<<<<<<<<
 *                 attr["target_name"],
 *                 attr["target_length"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2419; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_16 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_query_end); if (unlikely(__pyx_t_16 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2419; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_16);

      /* "plastid/genomics/roitools.pyx":2420
 *                 attr["query_start"],
 *                 attr["query_end"],
 *                 attr["target_name"],             # <<<<<<<<<<<<<<
 *                 attr["target_length"],
 *                 attr["target_start"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_17 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_target_name); if (unlikely(__pyx_t_17 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2420; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_17);

      /* "plastid/genomics/roitools.pyx":2421
 *                 attr["query_end"],
 *                 attr["target_name"],
 *                 attr["target_length"],             # <<<<<<<<<<<<<<
 *                 attr["target_start"],
 *                 attr["target_end"],
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2421; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_18 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_target_length); if (unlikely(__pyx_t_18 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2421; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_18);

      /* "plastid/genomics/roitools.pyx":2422
 *                 attr["target_name"],
 *                 attr["target_length"],
 *                 attr["target_start"],             # <<<<<<<<<<<<<<
 *                 attr["target_end"],
 *                 len(self),
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2422; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_19 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_target_start); if (unlikely(__pyx_t_19 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2422; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_19);

      /* "plastid/genomics/roitools.pyx":2423
 *                 attr["target_length"],
 *                 attr["target_start"],
 *                 attr["target_end"],             # <<<<<<<<<<<<<<
 *                 len(self),
 *             ]
 */
      if (unlikely(__pyx_v_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2423; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_20 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_target_end); if (unlikely(__pyx_t_20 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2423; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_20);

      /* "plastid/genomics/roitools.pyx":2424
 *                 attr["target_start"],
 *                 attr["target_end"],
 *                 len(self),             # <<<<<<<<<<<<<<
 *             ]
 * 
 */
      __pyx_t_21 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2424; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_t_22 = PyInt_FromSsize_t(__pyx_t_21); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2424; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_22);

      /* "plastid/genomics/roitools.pyx":2406
 *             str block_sizes, q_starts, t_starts
 *         try:
 *             ltmp = [             # <<<<<<<<<<<<<<
 *                 attr["match_length"],
 *                 attr["mismatches"],
 */
      __pyx_t_23 = PyList_New(18); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2406; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_GIVEREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_23, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_23, 1, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_23, 2, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_7);
      PyList_SET_ITEM(__pyx_t_23, 3, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_23, 4, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_23, 5, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10);
      PyList_SET_ITEM(__pyx_t_23, 6, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_11);
      PyList_SET_ITEM(__pyx_t_23, 7, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_12);
      PyList_SET_ITEM(__pyx_t_23, 8, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_13);
      PyList_SET_ITEM(__pyx_t_23, 9, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_14);
      PyList_SET_ITEM(__pyx_t_23, 10, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_15);
      PyList_SET_ITEM(__pyx_t_23, 11, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_16);
      PyList_SET_ITEM(__pyx_t_23, 12, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_17);
      PyList_SET_ITEM(__pyx_t_23, 13, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_18);
      PyList_SET_ITEM(__pyx_t_23, 14, __pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_19);
      PyList_SET_ITEM(__pyx_t_23, 15, __pyx_t_19);
      __Pyx_GIVEREF(__pyx_t_20);
      PyList_SET_ITEM(__pyx_t_23, 16, __pyx_t_20);
      __Pyx_GIVEREF(__pyx_t_22);
      PyList_SET_ITEM(__pyx_t_23, 17, __pyx_t_22);
      __pyx_t_1 = 0;
      __pyx_t_5 = 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_15 = 0;
      __pyx_t_16 = 0;
      __pyx_t_17 = 0;
      __pyx_t_18 = 0;
      __pyx_t_19 = 0;
      __pyx_t_20 = 0;
      __pyx_t_22 = 0;
      __Pyx_GIVEREF(__pyx_t_23);
      __pyx_cur_scope->__pyx_v_ltmp = ((PyObject*)__pyx_t_23);
      __pyx_t_23 = 0;

      /* "plastid/genomics/roitools.pyx":2427
 *             ]
 * 
 *             block_sizes = ",".join([str(len(X)) for X in self]) + ","             # <<<<<<<<<<<<<<
 *             q_starts = ",".join([str(X) for X in self.attr["q_starts"]]) + ","
 *             t_starts = ",".join([str(X) for X in self.attr["t_starts"]]) + ","
 */
      __pyx_t_23 = PyList_New(0); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
        __pyx_t_22 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_22); __pyx_t_21 = 0;
        __pyx_t_24 = NULL;
      } else {
        __pyx_t_21 = -1; __pyx_t_22 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_22);
        __pyx_t_24 = Py_TYPE(__pyx_t_22)->tp_iternext; if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      for (;;) {
        if (likely(!__pyx_t_24)) {
          if (likely(PyList_CheckExact(__pyx_t_22))) {
            if (__pyx_t_21 >= PyList_GET_SIZE(__pyx_t_22)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_20 = PyList_GET_ITEM(__pyx_t_22, __pyx_t_21); __Pyx_INCREF(__pyx_t_20); __pyx_t_21++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            #else
            __pyx_t_20 = PySequence_ITEM(__pyx_t_22, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            __Pyx_GOTREF(__pyx_t_20);
            #endif
          } else {
            if (__pyx_t_21 >= PyTuple_GET_SIZE(__pyx_t_22)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_20 = PyTuple_GET_ITEM(__pyx_t_22, __pyx_t_21); __Pyx_INCREF(__pyx_t_20); __pyx_t_21++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            #else
            __pyx_t_20 = PySequence_ITEM(__pyx_t_22, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            __Pyx_GOTREF(__pyx_t_20);
            #endif
          }
        } else {
          __pyx_t_20 = __pyx_t_24(__pyx_t_22);
          if (unlikely(!__pyx_t_20)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_20);
        }
        __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_20);
        __pyx_t_20 = 0;
        __pyx_t_25 = PyObject_Length(__pyx_v_X); if (unlikely(__pyx_t_25 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __pyx_t_20 = PyInt_FromSsize_t(__pyx_t_25); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __pyx_t_19 = PyTuple_New(1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_GIVEREF(__pyx_t_20);
        PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_20);
        __pyx_t_20 = 0;
        __pyx_t_20 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_19, NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_23, (PyObject*)__pyx_t_20))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      }
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      __pyx_t_22 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_t_23); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_22);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_23 = PyNumber_Add(__pyx_t_22, __pyx_kp_s_); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      if (!(likely(PyString_CheckExact(__pyx_t_23))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_23)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2427; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_block_sizes = ((PyObject*)__pyx_t_23);
      __pyx_t_23 = 0;

      /* "plastid/genomics/roitools.pyx":2428
 * 
 *             block_sizes = ",".join([str(len(X)) for X in self]) + ","
 *             q_starts = ",".join([str(X) for X in self.attr["q_starts"]]) + ","             # <<<<<<<<<<<<<<
 *             t_starts = ",".join([str(X) for X in self.attr["t_starts"]]) + ","
 * 
 */
      __pyx_t_23 = PyList_New(0); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      if (unlikely(__pyx_v_self->attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_22 = __Pyx_PyDict_GetItem(__pyx_v_self->attr, __pyx_n_s_q_starts); if (unlikely(__pyx_t_22 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_22);
      if (likely(PyList_CheckExact(__pyx_t_22)) || PyTuple_CheckExact(__pyx_t_22)) {
        __pyx_t_20 = __pyx_t_22; __Pyx_INCREF(__pyx_t_20); __pyx_t_21 = 0;
        __pyx_t_24 = NULL;
      } else {
        __pyx_t_21 = -1; __pyx_t_20 = PyObject_GetIter(__pyx_t_22); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __pyx_t_24 = Py_TYPE(__pyx_t_20)->tp_iternext; if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      for (;;) {
        if (likely(!__pyx_t_24)) {
          if (likely(PyList_CheckExact(__pyx_t_20))) {
            if (__pyx_t_21 >= PyList_GET_SIZE(__pyx_t_20)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_22 = PyList_GET_ITEM(__pyx_t_20, __pyx_t_21); __Pyx_INCREF(__pyx_t_22); __pyx_t_21++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            #else
            __pyx_t_22 = PySequence_ITEM(__pyx_t_20, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            __Pyx_GOTREF(__pyx_t_22);
            #endif
          } else {
            if (__pyx_t_21 >= PyTuple_GET_SIZE(__pyx_t_20)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_22 = PyTuple_GET_ITEM(__pyx_t_20, __pyx_t_21); __Pyx_INCREF(__pyx_t_22); __pyx_t_21++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            #else
            __pyx_t_22 = PySequence_ITEM(__pyx_t_20, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            __Pyx_GOTREF(__pyx_t_22);
            #endif
          }
        } else {
          __pyx_t_22 = __pyx_t_24(__pyx_t_20);
          if (unlikely(!__pyx_t_22)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_22);
        }
        __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_22);
        __pyx_t_22 = 0;
        __pyx_t_22 = PyTuple_New(1); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_22);
        __Pyx_INCREF(__pyx_v_X);
        __Pyx_GIVEREF(__pyx_v_X);
        PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_v_X);
        __pyx_t_19 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_22, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_23, (PyObject*)__pyx_t_19))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      }
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __pyx_t_20 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_t_23); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_23 = PyNumber_Add(__pyx_t_20, __pyx_kp_s_); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      if (!(likely(PyString_CheckExact(__pyx_t_23))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_23)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_q_starts = ((PyObject*)__pyx_t_23);
      __pyx_t_23 = 0;

      /* "plastid/genomics/roitools.pyx":2429
 *             block_sizes = ",".join([str(len(X)) for X in self]) + ","
 *             q_starts = ",".join([str(X) for X in self.attr["q_starts"]]) + ","
 *             t_starts = ",".join([str(X) for X in self.attr["t_starts"]]) + ","             # <<<<<<<<<<<<<<
 * 
 *             ltmp.append(block_sizes)
 */
      __pyx_t_23 = PyList_New(0); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      if (unlikely(__pyx_v_self->attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_20 = __Pyx_PyDict_GetItem(__pyx_v_self->attr, __pyx_n_s_t_starts); if (unlikely(__pyx_t_20 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_20);
      if (likely(PyList_CheckExact(__pyx_t_20)) || PyTuple_CheckExact(__pyx_t_20)) {
        __pyx_t_19 = __pyx_t_20; __Pyx_INCREF(__pyx_t_19); __pyx_t_21 = 0;
        __pyx_t_24 = NULL;
      } else {
        __pyx_t_21 = -1; __pyx_t_19 = PyObject_GetIter(__pyx_t_20); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_24 = Py_TYPE(__pyx_t_19)->tp_iternext; if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      for (;;) {
        if (likely(!__pyx_t_24)) {
          if (likely(PyList_CheckExact(__pyx_t_19))) {
            if (__pyx_t_21 >= PyList_GET_SIZE(__pyx_t_19)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_20 = PyList_GET_ITEM(__pyx_t_19, __pyx_t_21); __Pyx_INCREF(__pyx_t_20); __pyx_t_21++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            #else
            __pyx_t_20 = PySequence_ITEM(__pyx_t_19, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            __Pyx_GOTREF(__pyx_t_20);
            #endif
          } else {
            if (__pyx_t_21 >= PyTuple_GET_SIZE(__pyx_t_19)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_20 = PyTuple_GET_ITEM(__pyx_t_19, __pyx_t_21); __Pyx_INCREF(__pyx_t_20); __pyx_t_21++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            #else
            __pyx_t_20 = PySequence_ITEM(__pyx_t_19, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            __Pyx_GOTREF(__pyx_t_20);
            #endif
          }
        } else {
          __pyx_t_20 = __pyx_t_24(__pyx_t_19);
          if (unlikely(!__pyx_t_20)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_20);
        }
        __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_20);
        __pyx_t_20 = 0;
        __pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_INCREF(__pyx_v_X);
        __Pyx_GIVEREF(__pyx_v_X);
        PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_X);
        __pyx_t_22 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_20, NULL); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_22);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_23, (PyObject*)__pyx_t_22))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      }
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __pyx_t_19 = __Pyx_PyString_Join(__pyx_kp_s_, __pyx_t_23); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_23 = PyNumber_Add(__pyx_t_19, __pyx_kp_s_); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      if (!(likely(PyString_CheckExact(__pyx_t_23))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_23)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_t_starts = ((PyObject*)__pyx_t_23);
      __pyx_t_23 = 0;

      /* "plastid/genomics/roitools.pyx":2431
 *             t_starts = ",".join([str(X) for X in self.attr["t_starts"]]) + ","
 * 
 *             ltmp.append(block_sizes)             # <<<<<<<<<<<<<<
 *             ltmp.append(q_starts)
 *             ltmp.append(t_starts)
 */
      __pyx_t_26 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_ltmp, __pyx_v_block_sizes); if (unlikely(__pyx_t_26 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2431; __pyx_clineno = __LINE__; goto __pyx_L3_error;}

      /* "plastid/genomics/roitools.pyx":2432
 * 
 *             ltmp.append(block_sizes)
 *             ltmp.append(q_starts)             # <<<<<<<<<<<<<<
 *             ltmp.append(t_starts)
 *             return "\t".join(str(X) for X in ltmp) + "\n"
 */
      __pyx_t_26 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_ltmp, __pyx_v_q_starts); if (unlikely(__pyx_t_26 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2432; __pyx_clineno = __LINE__; goto __pyx_L3_error;}

      /* "plastid/genomics/roitools.pyx":2433
 *             ltmp.append(block_sizes)
 *             ltmp.append(q_starts)
 *             ltmp.append(t_starts)             # <<<<<<<<<<<<<<
 *             return "\t".join(str(X) for X in ltmp) + "\n"
 *         except KeyError:
 */
      __pyx_t_26 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_ltmp, __pyx_v_t_starts); if (unlikely(__pyx_t_26 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2433; __pyx_clineno = __LINE__; goto __pyx_L3_error;}

      /* "plastid/genomics/roitools.pyx":2434
 *             ltmp.append(q_starts)
 *             ltmp.append(t_starts)
 *             return "\t".join(str(X) for X in ltmp) + "\n"             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise AttributeError("SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end")
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_23 = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6as_psl_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      __pyx_t_19 = __Pyx_PyString_Join(__pyx_kp_s__17, __pyx_t_23); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_23 = PyNumber_Add(__pyx_t_19, __pyx_kp_s__18); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __pyx_r = __pyx_t_23;
      __pyx_t_23 = 0;
      goto __pyx_L7_try_return;

      /* "plastid/genomics/roitools.pyx":2405
 *             list ltmp
 *             str block_sizes, q_starts, t_starts
 *         try:             # <<<<<<<<<<<<<<
 *             ltmp = [
 *                 attr["match_length"],
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 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;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;

    /* "plastid/genomics/roitools.pyx":2435
 *             ltmp.append(t_starts)
 *             return "\t".join(str(X) for X in ltmp) + "\n"
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             raise AttributeError("SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end")
 * 
 */
    __pyx_t_27 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_27) {
      __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_psl", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_23, &__pyx_t_19, &__pyx_t_22) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2435; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_GOTREF(__pyx_t_22);

      /* "plastid/genomics/roitools.pyx":2436
 *             return "\t".join(str(X) for X in ltmp) + "\n"
 *         except KeyError:
 *             raise AttributeError("SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end")             # <<<<<<<<<<<<<<
 * 
 *     def get_segmentchain_coordinate(self, str chrom, long genomic_x, str strand, bint stranded = True):
 */
      __pyx_t_20 = __Pyx_PyObject_Call(__pyx_builtin_AttributeError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2436; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_20);
      __Pyx_Raise(__pyx_t_20, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2436; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "plastid/genomics/roitools.pyx":2405
 *             list ltmp
 *             str block_sizes, q_starts, t_starts
 *         try:             # <<<<<<<<<<<<<<
 *             ltmp = [
 *                 attr["match_length"],
 */
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":2350
 *             return ""
 * 
 *     def as_psl(self):             # <<<<<<<<<<<<<<
 *         """Formats |SegmentChain| as `PSL`_ (blat) output.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.as_psl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_block_sizes);
  __Pyx_XDECREF(__pyx_v_q_starts);
  __Pyx_XDECREF(__pyx_v_t_starts);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2438
 *             raise AttributeError("SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end")
 * 
 *     def get_segmentchain_coordinate(self, str chrom, long genomic_x, str strand, bint stranded = True):             # <<<<<<<<<<<<<<
 *         """Finds the |SegmentChain| coordinate corresponding to a genomic position
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_81get_segmentchain_coordinate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_80get_segmentchain_coordinate[] = "SegmentChain.get_segmentchain_coordinate(self, str chrom, long genomic_x, str strand, bool stranded=True)\nFinds the |SegmentChain| coordinate corresponding to a genomic position\n        \n        Parameters\n        ----------\n        chrom : str\n            Chromosome name\n            \n        genomic_x : int\n            coordinate, in genomic space\n            \n        strand : str\n            Chromosome strand (`'+'`, `'-'`, or `'.'`)\n            \n        stranded : bool, optional\n            If `True`, coordinates are given in stranded space\n            (i.e. from 5' end of chain, as one might expect for a transcript).\n            If `False`, coordinates are given from the left end of `self`,\n            regardless of strand. (Default: `True`)\n        \n        \n        Returns\n        -------\n        int\n            Position in |SegmentChain|\n            \n        Raises\n        ------\n        KeyError\n            if position outside bounds of |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_81get_segmentchain_coordinate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_chrom = 0;
  long __pyx_v_genomic_x;
  PyObject *__pyx_v_strand = 0;
  int __pyx_v_stranded;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_segmentchain_coordinate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_chrom,&__pyx_n_s_genomic_x,&__pyx_n_s_strand,&__pyx_n_s_stranded,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_chrom)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_genomic_x)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_segmentchain_coordinate", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_strand)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_segmentchain_coordinate", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stranded);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_segmentchain_coordinate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __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);
        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_chrom = ((PyObject*)values[0]);
    __pyx_v_genomic_x = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v_genomic_x == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_strand = ((PyObject*)values[2]);
    if (values[3]) {
      __pyx_v_stranded = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_stranded == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_stranded = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_segmentchain_coordinate", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_segmentchain_coordinate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chrom), (&PyString_Type), 1, "chrom", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_strand), (&PyString_Type), 1, "strand", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_80get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_chrom, __pyx_v_genomic_x, __pyx_v_strand, __pyx_v_stranded);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_80get_segmentchain_coordinate(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_chrom, long __pyx_v_genomic_x, PyObject *__pyx_v_strand, int __pyx_v_stranded) {
  long __pyx_v_retval;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_segmentchain_coordinate", 0);

  /* "plastid/genomics/roitools.pyx":2470
 *         """
 *         cdef long retval
 *         if chrom != self.chrom:             # <<<<<<<<<<<<<<
 *             raise ValueError("get_segmentchain_coordinate: query chromosome '%s' does not match chain '%s'" % chrom, self)
 *         if strand != self.strand:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chrom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_chrom, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":2471
 *         cdef long retval
 *         if chrom != self.chrom:
 *             raise ValueError("get_segmentchain_coordinate: query chromosome '%s' does not match chain '%s'" % chrom, self)             # <<<<<<<<<<<<<<
 *         if strand != self.strand:
 *             raise ValueError("get_segmentchain_coordinate: query strand '%s' does not match chain '%s'" % strand, self)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_get_segmentchain_coordinate_quer, __pyx_v_chrom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__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 = 2471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2470
 *         """
 *         cdef long retval
 *         if chrom != self.chrom:             # <<<<<<<<<<<<<<
 *             raise ValueError("get_segmentchain_coordinate: query chromosome '%s' does not match chain '%s'" % chrom, self)
 *         if strand != self.strand:
 */
  }

  /* "plastid/genomics/roitools.pyx":2472
 *         if chrom != self.chrom:
 *             raise ValueError("get_segmentchain_coordinate: query chromosome '%s' does not match chain '%s'" % chrom, self)
 *         if strand != self.strand:             # <<<<<<<<<<<<<<
 *             raise ValueError("get_segmentchain_coordinate: query strand '%s' does not match chain '%s'" % strand, self)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_strand, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":2473
 *             raise ValueError("get_segmentchain_coordinate: query chromosome '%s' does not match chain '%s'" % chrom, self)
 *         if strand != self.strand:
 *             raise ValueError("get_segmentchain_coordinate: query strand '%s' does not match chain '%s'" % strand, self)             # <<<<<<<<<<<<<<
 * 
 *         retval = self.c_get_segmentchain_coordinate(genomic_x,stranded)
 */
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_get_segmentchain_coordinate_quer_2, __pyx_v_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__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 = 2473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2472
 *         if chrom != self.chrom:
 *             raise ValueError("get_segmentchain_coordinate: query chromosome '%s' does not match chain '%s'" % chrom, self)
 *         if strand != self.strand:             # <<<<<<<<<<<<<<
 *             raise ValueError("get_segmentchain_coordinate: query strand '%s' does not match chain '%s'" % strand, self)
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2475
 *             raise ValueError("get_segmentchain_coordinate: query strand '%s' does not match chain '%s'" % strand, self)
 * 
 *         retval = self.c_get_segmentchain_coordinate(genomic_x,stranded)             # <<<<<<<<<<<<<<
 *         if retval == -1:
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: Genomic position %s not in SegmentChain %s." % (genomic_x,self))
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_segmentchain_coordinate(__pyx_v_self, __pyx_v_genomic_x, __pyx_v_stranded); if (unlikely(__pyx_t_4 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_retval = __pyx_t_4;

  /* "plastid/genomics/roitools.pyx":2476
 * 
 *         retval = self.c_get_segmentchain_coordinate(genomic_x,stranded)
 *         if retval == -1:             # <<<<<<<<<<<<<<
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: Genomic position %s not in SegmentChain %s." % (genomic_x,self))
 * 
 */
  __pyx_t_2 = ((__pyx_v_retval == -1L) != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":2477
 *         retval = self.c_get_segmentchain_coordinate(genomic_x,stranded)
 *         if retval == -1:
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: Genomic position %s not in SegmentChain %s." % (genomic_x,self))             # <<<<<<<<<<<<<<
 * 
 *         return retval
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_genomic_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self));
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_get_segmentchain_co, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2477; __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 = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__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 = 2477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2476
 * 
 *         retval = self.c_get_segmentchain_coordinate(genomic_x,stranded)
 *         if retval == -1:             # <<<<<<<<<<<<<<
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: Genomic position %s not in SegmentChain %s." % (genomic_x,self))
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2479
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: Genomic position %s not in SegmentChain %s." % (genomic_x,self))
 * 
 *         return retval             # <<<<<<<<<<<<<<
 * 
 *     cdef long c_get_segmentchain_coordinate(self, long genomic_x, bint stranded) except -1:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_retval); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2438
 *             raise AttributeError("SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end")
 * 
 *     def get_segmentchain_coordinate(self, str chrom, long genomic_x, str strand, bint stranded = True):             # <<<<<<<<<<<<<<
 *         """Finds the |SegmentChain| coordinate corresponding to a genomic position
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_segmentchain_coordinate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2481
 *         return retval
 * 
 *     cdef long c_get_segmentchain_coordinate(self, long genomic_x, bint stranded) except -1:             # <<<<<<<<<<<<<<
 *         """Finds the |SegmentChain| coordinate corresponding to a genomic position
 * 
 */

static long __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_segmentchain_coordinate(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, long __pyx_v_genomic_x, int __pyx_v_stranded) {
  PyObject *__pyx_v_ihash = 0;
  long __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  long __pyx_t_9;
  int __pyx_t_10;
  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("c_get_segmentchain_coordinate", 0);

  /* "plastid/genomics/roitools.pyx":2506
 *             if position outside bounds of |SegmentChain|
 *         """
 *         cdef dict ihash = self._get_inverse_hash()             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->_get_inverse_hash(__pyx_v_self); 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_v_ihash = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2508
 *         cdef dict ihash = self._get_inverse_hash()
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if self.c_strand == reverse_strand and stranded == True:
 *                 return self.length - ihash[genomic_x] - 1
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    /*try:*/ {

      /* "plastid/genomics/roitools.pyx":2509
 * 
 *         try:
 *             if self.c_strand == reverse_strand and stranded == True:             # <<<<<<<<<<<<<<
 *                 return self.length - ihash[genomic_x] - 1
 *             else:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_e_7plastid_8genomics_8c_common_reverse_strand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_8) {
      } else {
        __pyx_t_5 = __pyx_t_8;
        goto __pyx_L12_bool_binop_done;
      }
      __pyx_t_8 = ((__pyx_v_stranded == 1) != 0);
      __pyx_t_5 = __pyx_t_8;
      __pyx_L12_bool_binop_done:;
      if (__pyx_t_5) {

        /* "plastid/genomics/roitools.pyx":2510
 *         try:
 *             if self.c_strand == reverse_strand and stranded == True:
 *                 return self.length - ihash[genomic_x] - 1             # <<<<<<<<<<<<<<
 *             else:
 *                 return ihash[genomic_x]
 */
        __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_self->length); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_7);
        if (unlikely(__pyx_v_ihash == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_genomic_x); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_ihash, __pyx_t_6); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyNumber_Subtract(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_9 = __Pyx_PyInt_As_long(__pyx_t_1); if (unlikely((__pyx_t_9 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2510; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_r = __pyx_t_9;
        goto __pyx_L7_try_return;

        /* "plastid/genomics/roitools.pyx":2509
 * 
 *         try:
 *             if self.c_strand == reverse_strand and stranded == True:             # <<<<<<<<<<<<<<
 *                 return self.length - ihash[genomic_x] - 1
 *             else:
 */
      }

      /* "plastid/genomics/roitools.pyx":2512
 *                 return self.length - ihash[genomic_x] - 1
 *             else:
 *                 return ihash[genomic_x]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: genomic position '%s' is not in chain '%s'." % (genomic_x,self))
 */
      /*else*/ {
        if (unlikely(__pyx_v_ihash == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_genomic_x); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_ihash, __pyx_t_1); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_9 = __Pyx_PyInt_As_long(__pyx_t_6); if (unlikely((__pyx_t_9 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_r = __pyx_t_9;
        goto __pyx_L7_try_return;
      }

      /* "plastid/genomics/roitools.pyx":2508
 *         cdef dict ihash = self._get_inverse_hash()
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if self.c_strand == reverse_strand and stranded == True:
 *                 return self.length - ihash[genomic_x] - 1
 */
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":2513
 *             else:
 *                 return ihash[genomic_x]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: genomic position '%s' is not in chain '%s'." % (genomic_x,self))
 * 
 */
    __pyx_t_10 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_get_segmentchain_coordinate", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2513; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "plastid/genomics/roitools.pyx":2514
 *                 return ihash[genomic_x]
 *         except KeyError:
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: genomic position '%s' is not in chain '%s'." % (genomic_x,self))             # <<<<<<<<<<<<<<
 * 
 *     def get_genomic_coordinate(self,x,stranded=True):
 */
      __pyx_t_11 = __Pyx_PyInt_From_long(__pyx_v_genomic_x); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_12, 1, ((PyObject *)__pyx_v_self));
      __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyString_Format(__pyx_kp_s_SegmentChain_get_segmentchain_co_2, __pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__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 = 2514; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_KeyError, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_11, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "plastid/genomics/roitools.pyx":2508
 *         cdef dict ihash = self._get_inverse_hash()
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if self.c_strand == reverse_strand and stranded == True:
 *                 return self.length - ihash[genomic_x] - 1
 */
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":2481
 *         return retval
 * 
 *     cdef long c_get_segmentchain_coordinate(self, long genomic_x, bint stranded) except -1:             # <<<<<<<<<<<<<<
 *         """Finds the |SegmentChain| coordinate corresponding to a genomic position
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_get_segmentchain_coordinate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1L;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ihash);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2516
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: genomic position '%s' is not in chain '%s'." % (genomic_x,self))
 * 
 *     def get_genomic_coordinate(self,x,stranded=True):             # <<<<<<<<<<<<<<
 *         """Finds genomic coordinate corresponding to position `x` in `self`
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_83get_genomic_coordinate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_82get_genomic_coordinate[] = "SegmentChain.get_genomic_coordinate(self, x, stranded=True)\nFinds genomic coordinate corresponding to position `x` in `self`\n        \n        Parameters\n        ----------\n        x : int\n            position of interest, relative to |SegmentChain|\n            \n        stranded : bool, optional\n            If `True`, `x` is assumed to be in stranded space (i.e. counted from\n            5' end of chain, as one might expect for a transcript). If `False`,\n            coordinates assumed to be counted the left end of the `self`,\n            regardless of the strand of `self`. (Default: `True`)\n        \n                             \n        Returns\n        -------\n        str \n            Chromosome name\n        \n        long\n            Genomic cordinate corresponding to position `x`\n        \n        str\n            Chromosome strand (`'+'`, `'-'`, or `'.'`)\n        \n        \n        Raises\n        ------\n        IndexError\n            if `x` is outside the bounds of the |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_83get_genomic_coordinate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_stranded = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_genomic_coordinate (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_stranded,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_True);
    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_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stranded);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_genomic_coordinate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; __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_x = values[0];
    __pyx_v_stranded = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_genomic_coordinate", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2516; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_genomic_coordinate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_82get_genomic_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_x, __pyx_v_stranded);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_82get_genomic_coordinate(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_stranded) {
  long __pyx_v_new_x;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  int __pyx_t_2;
  long __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_genomic_coordinate", 0);

  /* "plastid/genomics/roitools.pyx":2548
 *             if `x` is outside the bounds of the |SegmentChain|
 *         """
 *         cdef long new_x = self.c_get_genomic_coordinate(x, stranded)             # <<<<<<<<<<<<<<
 *         if new_x == -1:
 *             raise RuntimeError("Cannot fetch coordinate %s from SegmentChain %s (length %s)" % (x,self,self.length))
 */
  __pyx_t_1 = __Pyx_PyInt_As_long(__pyx_v_x); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_stranded); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_genomic_coordinate(__pyx_v_self, __pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_new_x = __pyx_t_3;

  /* "plastid/genomics/roitools.pyx":2549
 *         """
 *         cdef long new_x = self.c_get_genomic_coordinate(x, stranded)
 *         if new_x == -1:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot fetch coordinate %s from SegmentChain %s (length %s)" % (x,self,self.length))
 * 
 */
  __pyx_t_2 = ((__pyx_v_new_x == -1L) != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":2550
 *         cdef long new_x = self.c_get_genomic_coordinate(x, stranded)
 *         if new_x == -1:
 *             raise RuntimeError("Cannot fetch coordinate %s from SegmentChain %s (length %s)" % (x,self,self.length))             # <<<<<<<<<<<<<<
 * 
 *         return self.chrom, new_x, self.strand
 */
    __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_self->length); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __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 = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_x);
    __Pyx_GIVEREF(__pyx_v_x);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_x);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_fetch_coordinate_s_from_S, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__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 = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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 = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2549
 *         """
 *         cdef long new_x = self.c_get_genomic_coordinate(x, stranded)
 *         if new_x == -1:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Cannot fetch coordinate %s from SegmentChain %s (length %s)" % (x,self,self.length))
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2552
 *             raise RuntimeError("Cannot fetch coordinate %s from SegmentChain %s (length %s)" % (x,self,self.length))
 * 
 *         return self.chrom, new_x, self.strand             # <<<<<<<<<<<<<<
 * 
 *     cdef long c_get_genomic_coordinate(self, long x, bint stranded) except -1:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chrom); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_new_x); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2516
 *             raise KeyError("SegmentChain.get_segmentchain_coordinate: genomic position '%s' is not in chain '%s'." % (genomic_x,self))
 * 
 *     def get_genomic_coordinate(self,x,stranded=True):             # <<<<<<<<<<<<<<
 *         """Finds genomic coordinate corresponding to position `x` in `self`
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_genomic_coordinate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2554
 *         return self.chrom, new_x, self.strand
 * 
 *     cdef long c_get_genomic_coordinate(self, long x, bint stranded) except -1:             # <<<<<<<<<<<<<<
 *         """Finds genomic coordinate corresponding to position `x` in `self`
 * 
 */

static long __pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_genomic_coordinate(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, long __pyx_v_x, int __pyx_v_stranded) {
  long __pyx_v_length;
  long __pyx_v_orig_index;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_strand;
  long __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  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("c_get_genomic_coordinate", 0);

  /* "plastid/genomics/roitools.pyx":2585
 *         """
 *         cdef:
 *             long length = self.length             # <<<<<<<<<<<<<<
 *             long orig_index = x
 *             Strand strand = self.c_strand
 */
  __pyx_t_1 = __pyx_v_self->length;
  __pyx_v_length = __pyx_t_1;

  /* "plastid/genomics/roitools.pyx":2586
 *         cdef:
 *             long length = self.length
 *             long orig_index = x             # <<<<<<<<<<<<<<
 *             Strand strand = self.c_strand
 * 
 */
  __pyx_v_orig_index = __pyx_v_x;

  /* "plastid/genomics/roitools.pyx":2587
 *             long length = self.length
 *             long orig_index = x
 *             Strand strand = self.c_strand             # <<<<<<<<<<<<<<
 * 
 *         if strand == reverse_strand and stranded == True:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((enum __pyx_t_7plastid_8genomics_8c_common_Strand)__Pyx_PyInt_As_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_t_2)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_strand = __pyx_t_3;

  /* "plastid/genomics/roitools.pyx":2589
 *             Strand strand = self.c_strand
 * 
 *         if strand == reverse_strand and stranded == True:             # <<<<<<<<<<<<<<
 *             x = length - x - 1
 * 
 */
  __pyx_t_5 = ((__pyx_v_strand == __pyx_e_7plastid_8genomics_8c_common_reverse_strand) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_stranded == 1) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":2590
 * 
 *         if strand == reverse_strand and stranded == True:
 *             x = length - x - 1             # <<<<<<<<<<<<<<
 * 
 *         if x < 0 or x >= length:
 */
    __pyx_v_x = ((__pyx_v_length - __pyx_v_x) - 1);

    /* "plastid/genomics/roitools.pyx":2589
 *             Strand strand = self.c_strand
 * 
 *         if strand == reverse_strand and stranded == True:             # <<<<<<<<<<<<<<
 *             x = length - x - 1
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2592
 *             x = length - x - 1
 * 
 *         if x < 0 or x >= length:             # <<<<<<<<<<<<<<
 *             raise IndexError("Position %s is outside bounds [0,%s) of SegmentChain '%s'" % (orig_index, length, self.get_name()))
 * 
 */
  __pyx_t_5 = ((__pyx_v_x < 0) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_4 = __pyx_t_5;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_x >= __pyx_v_length) != 0);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":2593
 * 
 *         if x < 0 or x >= length:
 *             raise IndexError("Position %s is outside bounds [0,%s) of SegmentChain '%s'" % (orig_index, length, self.get_name()))             # <<<<<<<<<<<<<<
 * 
 *         return self._position_hash[x]
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_orig_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_length); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __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 = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Position_s_is_outside_bounds_0_s, __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __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(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2592
 *             x = length - x - 1
 * 
 *         if x < 0 or x >= length:             # <<<<<<<<<<<<<<
 *             raise IndexError("Position %s is outside bounds [0,%s) of SegmentChain '%s'" % (orig_index, length, self.get_name()))
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2595
 *             raise IndexError("Position %s is outside bounds [0,%s) of SegmentChain '%s'" % (orig_index, length, self.get_name()))
 * 
 *         return self._position_hash[x]             # <<<<<<<<<<<<<<
 * 
 *     def get_subchain(self, long start, long end, bint stranded=True, **extra_attr):
 */
  __pyx_t_7 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->_position_hash), __pyx_v_x, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2595; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyInt_As_long(__pyx_t_7); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2554
 *         return self.chrom, new_x, self.strand
 * 
 *     cdef long c_get_genomic_coordinate(self, long x, bint stranded) except -1:             # <<<<<<<<<<<<<<
 *         """Finds genomic coordinate corresponding to position `x` in `self`
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_get_genomic_coordinate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1L;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2597
 *         return self._position_hash[x]
 * 
 *     def get_subchain(self, long start, long end, bint stranded=True, **extra_attr):             # <<<<<<<<<<<<<<
 *         """Retrieves a sub-|SegmentChain| corresponding a range of positions
 *         specified in coordinates relative this |SegmentChain|. Attributes in
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_85get_subchain(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_84get_subchain[] = "SegmentChain.get_subchain(self, long start, long end, bool stranded=True, **extra_attr)\nRetrieves a sub-|SegmentChain| corresponding a range of positions\n        specified in coordinates relative this |SegmentChain|. Attributes in\n        `self.attr` are copied to the child SegmentChain, with the exception\n        of `ID`, to which the suffix `'subchain'` is appended.\n        \n        Parameters\n        ----------\n        start : int\n            position of interest in SegmentChain coordinates, 0-indexed\n            \n        end : int\n            position of interest in SegmentChain coordinates, 0-indexed \n            and half-open\n            \n        stranded : bool, optional\n            If `True`, `start` and `end` are assumed to be in stranded space (i.e. counted from\n            5' end of chain, as one might expect for a transcript). If `False`,\n            they assumed to be counted the left end of the `self`,\n            regardless of the strand of `self`. (Default: `True`)\n\n        extra_attr : keyword arguments\n            Values that will be included in the subchain's `attr` dict.\n            These can be used to overwrite values already present.\n                          \n        Returns\n        -------\n        |SegmentChain|\n            covering parent chain positions `start` to `end` of `self`\n        \n        \n        Raises\n        ------\n        IndexError\n            if `start` or `end` is outside the bounds of the |SegmentChain|\n\n        TypeError\n            if `start` or `end` is None\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_85get_subchain(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  long __pyx_v_start;
  long __pyx_v_end;
  int __pyx_v_stranded;
  PyObject *__pyx_v_extra_attr = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_subchain (wrapper)", 0);
  __pyx_v_extra_attr = PyDict_New(); if (unlikely(!__pyx_v_extra_attr)) return NULL;
  __Pyx_GOTREF(__pyx_v_extra_attr);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_start,&__pyx_n_s_end,&__pyx_n_s_stranded,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_start)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_subchain", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stranded);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_extra_attr, values, pos_args, "get_subchain") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __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_start = __Pyx_PyInt_As_long(values[0]); if (unlikely((__pyx_v_start == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_end = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v_end == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[2]) {
      __pyx_v_stranded = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_stranded == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_stranded = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_subchain", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_extra_attr); __pyx_v_extra_attr = 0;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_subchain", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_84get_subchain(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_start, __pyx_v_end, __pyx_v_stranded, __pyx_v_extra_attr);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_extra_attr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_84get_subchain(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, long __pyx_v_start, long __pyx_v_end, int __pyx_v_stranded, PyObject *__pyx_v_extra_attr) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_chain = 0;
  PyObject *__pyx_v_old_attr = 0;
  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("get_subchain", 0);

  /* "plastid/genomics/roitools.pyx":2637
 *         """
 *         cdef:
 *             SegmentChain chain = self.c_get_subchain(start,end,stranded)             # <<<<<<<<<<<<<<
 *             dict old_attr = copy.deepcopy(self.attr)
 * 
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self->__pyx_vtab)->c_get_subchain(__pyx_v_self, __pyx_v_start, __pyx_v_end, __pyx_v_stranded)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_chain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2638
 *         cdef:
 *             SegmentChain chain = self.c_get_subchain(start,end,stranded)
 *             dict old_attr = copy.deepcopy(self.attr)             # <<<<<<<<<<<<<<
 * 
 *         old_attr.update(extra_attr)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->attr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->attr);
    __Pyx_GIVEREF(__pyx_v_self->attr);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->attr);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_old_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2640
 *             dict old_attr = copy.deepcopy(self.attr)
 * 
 *         old_attr.update(extra_attr)             # <<<<<<<<<<<<<<
 *         chain.attr = old_attr
 *         chain.attr["ID"] = "%s_subchain" % self.get_name()
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_old_attr, __pyx_n_s_update); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_extra_attr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); 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_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_extra_attr);
    __Pyx_GIVEREF(__pyx_v_extra_attr);
    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_extra_attr);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2641
 * 
 *         old_attr.update(extra_attr)
 *         chain.attr = old_attr             # <<<<<<<<<<<<<<
 *         chain.attr["ID"] = "%s_subchain" % self.get_name()
 *         return chain
 */
  __Pyx_INCREF(__pyx_v_old_attr);
  __Pyx_GIVEREF(__pyx_v_old_attr);
  __Pyx_GOTREF(__pyx_v_chain->attr);
  __Pyx_DECREF(__pyx_v_chain->attr);
  __pyx_v_chain->attr = __pyx_v_old_attr;

  /* "plastid/genomics/roitools.pyx":2642
 *         old_attr.update(extra_attr)
 *         chain.attr = old_attr
 *         chain.attr["ID"] = "%s_subchain" % self.get_name()             # <<<<<<<<<<<<<<
 *         return chain
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_subchain, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_v_chain->attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(PyDict_SetItem(__pyx_v_chain->attr, __pyx_n_s_ID, __pyx_t_3) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "plastid/genomics/roitools.pyx":2643
 *         chain.attr = old_attr
 *         chain.attr["ID"] = "%s_subchain" % self.get_name()
 *         return chain             # <<<<<<<<<<<<<<
 * 
 *     cdef SegmentChain c_get_subchain(self, long start, long end, bint stranded):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_chain));
  __pyx_r = ((PyObject *)__pyx_v_chain);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2597
 *         return self._position_hash[x]
 * 
 *     def get_subchain(self, long start, long end, bint stranded=True, **extra_attr):             # <<<<<<<<<<<<<<
 *         """Retrieves a sub-|SegmentChain| corresponding a range of positions
 *         specified in coordinates relative this |SegmentChain|. Attributes in
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.get_subchain", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_chain);
  __Pyx_XDECREF(__pyx_v_old_attr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2645
 *         return chain
 * 
 *     cdef SegmentChain c_get_subchain(self, long start, long end, bint stranded):             # <<<<<<<<<<<<<<
 *         """Similar to :meth:`SegmentChain.get_subchain` but does not copy `attr` dict
 * 
 */

static struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_subchain(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, long __pyx_v_start, long __pyx_v_end, int __pyx_v_stranded) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_chain = 0;
  long __pyx_v_length;
  long __pyx_v_tmp;
  PyObject *__pyx_v_segs = 0;
  PyObject *__pyx_v_positions = NULL;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  long __pyx_t_2;
  int __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("c_get_subchain", 0);

  /* "plastid/genomics/roitools.pyx":2673
 *         """
 *         cdef:
 *             SegmentChain chain = SegmentChain()             # <<<<<<<<<<<<<<
 *             long length = self.length
 *             long tmp
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_chain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2674
 *         cdef:
 *             SegmentChain chain = SegmentChain()
 *             long length = self.length             # <<<<<<<<<<<<<<
 *             long tmp
 *             list segs
 */
  __pyx_t_2 = __pyx_v_self->length;
  __pyx_v_length = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":2678
 *             list segs
 * 
 *         if start == end: # this is a special case which we need to account for             # <<<<<<<<<<<<<<
 *             return SegmentChain()
 * 
 */
  __pyx_t_3 = ((__pyx_v_start == __pyx_v_end) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2679
 * 
 *         if start == end: # this is a special case which we need to account for
 *             return SegmentChain()             # <<<<<<<<<<<<<<
 * 
 *         if start is None:
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":2678
 *             list segs
 * 
 *         if start == end: # this is a special case which we need to account for             # <<<<<<<<<<<<<<
 *             return SegmentChain()
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2681
 *             return SegmentChain()
 * 
 *         if start is None:             # <<<<<<<<<<<<<<
 *             raise TypeError('start coordinate supplied is None. Expected int')
 *         elif end is None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (__pyx_t_1 == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":2682
 * 
 *         if start is None:
 *             raise TypeError('start coordinate supplied is None. Expected int')             # <<<<<<<<<<<<<<
 *         elif end is None:
 *             raise TypeError('end coordinate supplied is None. Expected int')
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2682; __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 = 2682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2681
 *             return SegmentChain()
 * 
 *         if start is None:             # <<<<<<<<<<<<<<
 *             raise TypeError('start coordinate supplied is None. Expected int')
 *         elif end is None:
 */
  }

  /* "plastid/genomics/roitools.pyx":2683
 *         if start is None:
 *             raise TypeError('start coordinate supplied is None. Expected int')
 *         elif end is None:             # <<<<<<<<<<<<<<
 *             raise TypeError('end coordinate supplied is None. Expected int')
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = (__pyx_t_1 == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2684
 *             raise TypeError('start coordinate supplied is None. Expected int')
 *         elif end is None:
 *             raise TypeError('end coordinate supplied is None. Expected int')             # <<<<<<<<<<<<<<
 * 
 *         if stranded == True and self.c_strand == reverse_strand:
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __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 = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2683
 *         if start is None:
 *             raise TypeError('start coordinate supplied is None. Expected int')
 *         elif end is None:             # <<<<<<<<<<<<<<
 *             raise TypeError('end coordinate supplied is None. Expected int')
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2686
 *             raise TypeError('end coordinate supplied is None. Expected int')
 * 
 *         if stranded == True and self.c_strand == reverse_strand:             # <<<<<<<<<<<<<<
 *             tmp = end
 *             end   = length - start
 */
  __pyx_t_4 = ((__pyx_v_stranded == 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_e_7plastid_8genomics_8c_common_reverse_strand); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = __pyx_t_4;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2687
 * 
 *         if stranded == True and self.c_strand == reverse_strand:
 *             tmp = end             # <<<<<<<<<<<<<<
 *             end   = length - start
 *             start = length - tmp
 */
    __pyx_v_tmp = __pyx_v_end;

    /* "plastid/genomics/roitools.pyx":2688
 *         if stranded == True and self.c_strand == reverse_strand:
 *             tmp = end
 *             end   = length - start             # <<<<<<<<<<<<<<
 *             start = length - tmp
 * 
 */
    __pyx_v_end = (__pyx_v_length - __pyx_v_start);

    /* "plastid/genomics/roitools.pyx":2689
 *             tmp = end
 *             end   = length - start
 *             start = length - tmp             # <<<<<<<<<<<<<<
 * 
 *         positions = self._position_hash[start:end].tolist()
 */
    __pyx_v_start = (__pyx_v_length - __pyx_v_tmp);

    /* "plastid/genomics/roitools.pyx":2686
 *             raise TypeError('end coordinate supplied is None. Expected int')
 * 
 *         if stranded == True and self.c_strand == reverse_strand:             # <<<<<<<<<<<<<<
 *             tmp = end
 *             end   = length - start
 */
  }

  /* "plastid/genomics/roitools.pyx":2691
 *             start = length - tmp
 * 
 *         positions = self._position_hash[start:end].tolist()             # <<<<<<<<<<<<<<
 *         segs = positionlist_to_segments(self.chrom,self.strand,positions)
 *         chain._set_segments(segs)
 */
  __pyx_t_5 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->_position_hash), __pyx_v_start, __pyx_v_end, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_positions = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "plastid/genomics/roitools.pyx":2692
 * 
 *         positions = self._position_hash[start:end].tolist()
 *         segs = positionlist_to_segments(self.chrom,self.strand,positions)             # <<<<<<<<<<<<<<
 *         chain._set_segments(segs)
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chrom); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(PyString_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyList_CheckExact(__pyx_v_positions))||((__pyx_v_positions) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_positions)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments(((PyObject*)__pyx_t_6), ((PyObject*)__pyx_t_1), ((PyObject*)__pyx_v_positions), 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2692; __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_1); __pyx_t_1 = 0;
  __pyx_v_segs = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "plastid/genomics/roitools.pyx":2693
 *         positions = self._position_hash[start:end].tolist()
 *         segs = positionlist_to_segments(self.chrom,self.strand,positions)
 *         chain._set_segments(segs)             # <<<<<<<<<<<<<<
 * 
 *         return chain
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain->__pyx_vtab)->_set_segments(__pyx_v_chain, __pyx_v_segs); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":2695
 *         chain._set_segments(segs)
 * 
 *         return chain             # <<<<<<<<<<<<<<
 * 
 *     def get_counts(self,ga,stranded=True):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_chain));
  __pyx_r = __pyx_v_chain;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2645
 *         return chain
 * 
 *     cdef SegmentChain c_get_subchain(self, long start, long end, bint stranded):             # <<<<<<<<<<<<<<
 *         """Similar to :meth:`SegmentChain.get_subchain` but does not copy `attr` dict
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.c_get_subchain", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_chain);
  __Pyx_XDECREF(__pyx_v_segs);
  __Pyx_XDECREF(__pyx_v_positions);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2697
 *         return chain
 * 
 *     def get_counts(self,ga,stranded=True):             # <<<<<<<<<<<<<<
 *         """Return list of counts or values at each position in `self`
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_87get_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_86get_counts[] = "SegmentChain.get_counts(self, ga, stranded=True)\nReturn list of counts or values at each position in `self`\n        \n        Parameters\n        ----------\n        ga : non-abstract subclass of |AbstractGenomeArray|\n            GenomeArray from which to fetch counts\n            \n        stranded : bool, optional\n            If `True` and the SegmentChain is on the minus strand,\n            count order will be reversed relative to genome so that the\n            array positions march from the 5' to 3' end of the chain.\n            (Default: `True`)\n            \n            \n        Returns\n        -------\n        numpy.ndarray\n            Array of counts from `ga` covering `self`\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_87get_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ga = 0;
  PyObject *__pyx_v_stranded = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ga,&__pyx_n_s_stranded,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_True);
    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_ga)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stranded);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __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_ga = values[0];
    __pyx_v_stranded = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_counts", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_86get_counts(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_ga, __pyx_v_stranded);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_86get_counts(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_ga, PyObject *__pyx_v_stranded) {
  long __pyx_v_c;
  long __pyx_v_cend;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg = 0;
  PyArrayObject *__pyx_v_count_array = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_count_array;
  __Pyx_Buffer __pyx_pybuffer_count_array;
  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;
  PyArrayObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  Py_ssize_t __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __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("get_counts", 0);
  __pyx_pybuffer_count_array.pybuffer.buf = NULL;
  __pyx_pybuffer_count_array.refcount = 0;
  __pyx_pybuffernd_count_array.data = NULL;
  __pyx_pybuffernd_count_array.rcbuffer = &__pyx_pybuffer_count_array;

  /* "plastid/genomics/roitools.pyx":2720
 *             long c, cend
 *             GenomicSegment seg
 *             numpy.ndarray[DOUBLE_t,ndim=1] count_array = numpy.zeros(self.length,dtype=DOUBLE)             # <<<<<<<<<<<<<<
 * 
 *         if len(self) == 0:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __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_From_long(__pyx_v_self->length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __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 = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_count_array.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_DOUBLE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_count_array = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_count_array.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_count_array.diminfo[0].strides = __pyx_pybuffernd_count_array.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_count_array.diminfo[0].shape = __pyx_pybuffernd_count_array.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_count_array = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":2722
 *             numpy.ndarray[DOUBLE_t,ndim=1] count_array = numpy.zeros(self.length,dtype=DOUBLE)
 * 
 *         if len(self) == 0:             # <<<<<<<<<<<<<<
 *             warnings.warn("%s is a zero-length SegmentChain. Returning 0-length count vector." % self.get_name(),DataWarning)
 * 
 */
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((__pyx_t_6 == 0) != 0);
  if (__pyx_t_7) {

    /* "plastid/genomics/roitools.pyx":2723
 * 
 *         if len(self) == 0:
 *             warnings.warn("%s is a zero-length SegmentChain. Returning 0-length count vector." % self.get_name(),DataWarning)             # <<<<<<<<<<<<<<
 * 
 *         c = 0
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_is_a_zero_length_SegmentChain, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __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_GetModuleGlobalName(__pyx_n_s_DataWarning); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_9 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "plastid/genomics/roitools.pyx":2722
 *             numpy.ndarray[DOUBLE_t,ndim=1] count_array = numpy.zeros(self.length,dtype=DOUBLE)
 * 
 *         if len(self) == 0:             # <<<<<<<<<<<<<<
 *             warnings.warn("%s is a zero-length SegmentChain. Returning 0-length count vector." % self.get_name(),DataWarning)
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2725
 *             warnings.warn("%s is a zero-length SegmentChain. Returning 0-length count vector." % self.get_name(),DataWarning)
 * 
 *         c = 0             # <<<<<<<<<<<<<<
 *         for seg in self:
 *             cend = c + len(seg)
 */
  __pyx_v_c = 0;

  /* "plastid/genomics/roitools.pyx":2726
 * 
 *         c = 0
 *         for seg in self:             # <<<<<<<<<<<<<<
 *             cend = c + len(seg)
 *             count_array[c:cend] = ga.__getitem__(seg,roi_order=False)
 */
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
    __pyx_t_4 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_10)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_10(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __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_7plastid_8genomics_8roitools_GenomicSegment))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_seg, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":2727
 *         c = 0
 *         for seg in self:
 *             cend = c + len(seg)             # <<<<<<<<<<<<<<
 *             count_array[c:cend] = ga.__getitem__(seg,roi_order=False)
 *             c = cend
 */
    __pyx_t_11 = PyObject_Length(((PyObject *)__pyx_v_seg)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_cend = (__pyx_v_c + __pyx_t_11);

    /* "plastid/genomics/roitools.pyx":2728
 *         for seg in self:
 *             cend = c + len(seg)
 *             count_array[c:cend] = ga.__getitem__(seg,roi_order=False)             # <<<<<<<<<<<<<<
 *             c = cend
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ga, __pyx_n_s_getitem); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(((PyObject *)__pyx_v_seg));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_seg));
    PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_seg));
    __pyx_t_1 = PyDict_New(); 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);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_roi_order, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __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_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PyObject_SetSlice(((PyObject *)__pyx_v_count_array), __pyx_t_2, __pyx_v_c, __pyx_v_cend, NULL, NULL, NULL, 1, 1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":2729
 *             cend = c + len(seg)
 *             count_array[c:cend] = ga.__getitem__(seg,roi_order=False)
 *             c = cend             # <<<<<<<<<<<<<<
 * 
 *         if self.c_strand == reverse_strand and stranded is True:
 */
    __pyx_v_c = __pyx_v_cend;

    /* "plastid/genomics/roitools.pyx":2726
 * 
 *         c = 0
 *         for seg in self:             # <<<<<<<<<<<<<<
 *             cend = c + len(seg)
 *             count_array[c:cend] = ga.__getitem__(seg,roi_order=False)
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":2731
 *             c = cend
 * 
 *         if self.c_strand == reverse_strand and stranded is True:             # <<<<<<<<<<<<<<
 *             count_array = count_array[::-1]
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_e_7plastid_8genomics_8c_common_reverse_strand); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_12) {
  } else {
    __pyx_t_7 = __pyx_t_12;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_12 = (__pyx_v_stranded == Py_True);
  __pyx_t_13 = (__pyx_t_12 != 0);
  __pyx_t_7 = __pyx_t_13;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_7) {

    /* "plastid/genomics/roitools.pyx":2732
 * 
 *         if self.c_strand == reverse_strand and stranded is True:
 *             count_array = count_array[::-1]             # <<<<<<<<<<<<<<
 * 
 *         return count_array
 */
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_count_array), __pyx_slice__23); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2732; __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_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_count_array.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_count_array.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_DOUBLE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_count_array.rcbuffer->pybuffer, (PyObject*)__pyx_v_count_array, &__Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_DOUBLE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
        }
      }
      __pyx_pybuffernd_count_array.diminfo[0].strides = __pyx_pybuffernd_count_array.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_count_array.diminfo[0].shape = __pyx_pybuffernd_count_array.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_count_array, ((PyArrayObject *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":2731
 *             c = cend
 * 
 *         if self.c_strand == reverse_strand and stranded is True:             # <<<<<<<<<<<<<<
 *             count_array = count_array[::-1]
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2734
 *             count_array = count_array[::-1]
 * 
 *         return count_array             # <<<<<<<<<<<<<<
 * 
 *     def get_masked_counts(self,ga,stranded=True,copy=False):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_count_array));
  __pyx_r = ((PyObject *)__pyx_v_count_array);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2697
 *         return chain
 * 
 *     def get_counts(self,ga,stranded=True):             # <<<<<<<<<<<<<<
 *         """Return list of counts or values at each position in `self`
 * 
 */

  /* function exit code */
  __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_8);
  __Pyx_XDECREF(__pyx_t_9);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_count_array.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_count_array.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_seg);
  __Pyx_XDECREF((PyObject *)__pyx_v_count_array);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2736
 *         return count_array
 * 
 *     def get_masked_counts(self,ga,stranded=True,copy=False):             # <<<<<<<<<<<<<<
 *         """Return counts covering `self` in dataset `gnd` as a masked array, in transcript
 *         coordinates. Positions masked by :py:meth:`SegmentChain.add_mask`
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_89get_masked_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_88get_masked_counts[] = "SegmentChain.get_masked_counts(self, ga, stranded=True, copy=False)\nReturn counts covering `self` in dataset `gnd` as a masked array, in transcript \n        coordinates. Positions masked by :py:meth:`SegmentChain.add_mask` \n        will be masked in the array\n        \n        Parameters\n        ----------\n        gnd : non-abstract subclass of |AbstractGenomeArray|\n            GenomeArray from which to fetch counts\n            \n        stranded : bool, optional\n            If true and the |SegmentChain| is on the minus strand,\n            count order will be reversed relative to genome so that the\n            array positions march from the 5' to 3' end of the chain.\n            (Default: `True`)\n\n        copy : bool, optional\n            If `False` (defualt) returns a view of the data; so changing\n            values in the view changes the values in the |GenomeArray|\n            if it is mutable. If `True`, a copy is returned instead.\n            \n            \n        Returns\n        -------\n\t\t:py:class:`numpy.ma.masked_array`\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_89get_masked_counts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_ga = 0;
  CYTHON_UNUSED PyObject *__pyx_v_stranded = 0;
  PyObject *__pyx_v_copy = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_masked_counts (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ga,&__pyx_n_s_stranded,&__pyx_n_s_copy,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_True);
    values[2] = ((PyObject *)Py_False);
    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_ga)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stranded);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_copy);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_masked_counts") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2736; __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_ga = values[0];
    __pyx_v_stranded = values[1];
    __pyx_v_copy = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_masked_counts", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2736; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_masked_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_88get_masked_counts(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_ga, __pyx_v_stranded, __pyx_v_copy);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_88get_masked_counts(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_ga, CYTHON_UNUSED PyObject *__pyx_v_stranded, PyObject *__pyx_v_copy) {
  PyArrayObject *__pyx_v_counts = 0;
  PyArrayObject *__pyx_v_mask = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_counts;
  __Pyx_Buffer __pyx_pybuffer_counts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_mask;
  __Pyx_Buffer __pyx_pybuffer_mask;
  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;
  PyArrayObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_masked_counts", 0);
  __pyx_pybuffer_counts.pybuffer.buf = NULL;
  __pyx_pybuffer_counts.refcount = 0;
  __pyx_pybuffernd_counts.data = NULL;
  __pyx_pybuffernd_counts.rcbuffer = &__pyx_pybuffer_counts;
  __pyx_pybuffer_mask.pybuffer.buf = NULL;
  __pyx_pybuffer_mask.refcount = 0;
  __pyx_pybuffernd_mask.data = NULL;
  __pyx_pybuffernd_mask.rcbuffer = &__pyx_pybuffer_mask;

  /* "plastid/genomics/roitools.pyx":2763
 *         """
 *         cdef:
 *             numpy.ndarray[DOUBLE_t,ndim=1] counts = self.get_counts(ga)             # <<<<<<<<<<<<<<
 *             numpy.ndarray[int,ndim=1] mask #= numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_counts); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_ga); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_ga);
    __Pyx_GIVEREF(__pyx_v_ga);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_ga);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_counts.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_7plastid_8genomics_8roitools_DOUBLE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_counts = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_counts.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_counts.diminfo[0].strides = __pyx_pybuffernd_counts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_counts.diminfo[0].shape = __pyx_pybuffernd_counts.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_counts = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2766
 *             numpy.ndarray[int,ndim=1] mask #= numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 * 
 *         if len(self._position_mask) == 0:             # <<<<<<<<<<<<<<
 *             mask = numpy.zeros(len(counts),dtype=numpy.intc)
 *         else:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->_position_mask);
  __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 = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_6 = Py_SIZE(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = ((__pyx_t_6 == 0) != 0);
  if (__pyx_t_7) {

    /* "plastid/genomics/roitools.pyx":2767
 * 
 *         if len(self._position_mask) == 0:
 *             mask = numpy.zeros(len(counts),dtype=numpy.intc)             # <<<<<<<<<<<<<<
 *         else:
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); 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_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_counts)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); 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_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); 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_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_intc); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __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_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_8);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        }
      }
      __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_9 = 0;
    __pyx_v_mask = ((PyArrayObject *)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "plastid/genomics/roitools.pyx":2766
 *             numpy.ndarray[int,ndim=1] mask #= numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 * 
 *         if len(self._position_mask) == 0:             # <<<<<<<<<<<<<<
 *             mask = numpy.zeros(len(counts),dtype=numpy.intc)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":2769
 *             mask = numpy.zeros(len(counts),dtype=numpy.intc)
 *         else:
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)             # <<<<<<<<<<<<<<
 *             if self.c_strand == reverse_strand:
 *                 mask = mask[::-1]
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__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 = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->_position_mask));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->_position_mask));
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_self->_position_mask));
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_intc); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __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_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
        }
      }
      __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_9 = 0;
    __pyx_v_mask = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":2770
 *         else:
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 *             if self.c_strand == reverse_strand:             # <<<<<<<<<<<<<<
 *                 mask = mask[::-1]
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_c_strand); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(__pyx_e_7plastid_8genomics_8c_common_reverse_strand); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_7) {

      /* "plastid/genomics/roitools.pyx":2771
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 *             if self.c_strand == reverse_strand:
 *                 mask = mask[::-1]             # <<<<<<<<<<<<<<
 * 
 *         return MaskedArray(counts,mask=mask.astype(bool),copy=copy)
 */
      __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_mask), __pyx_slice__24); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2771; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_8);
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = ((PyArrayObject *)__pyx_t_8);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
        __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_10 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_mask.rcbuffer->pybuffer, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_int, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_mask.diminfo[0].strides = __pyx_pybuffernd_mask.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_mask.diminfo[0].shape = __pyx_pybuffernd_mask.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_9 = 0;
      __Pyx_DECREF_SET(__pyx_v_mask, ((PyArrayObject *)__pyx_t_8));
      __pyx_t_8 = 0;

      /* "plastid/genomics/roitools.pyx":2770
 *         else:
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 *             if self.c_strand == reverse_strand:             # <<<<<<<<<<<<<<
 *                 mask = mask[::-1]
 * 
 */
    }
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":2773
 *                 mask = mask[::-1]
 * 
 *         return MaskedArray(counts,mask=mask.astype(bool),copy=copy)             # <<<<<<<<<<<<<<
 * 
 *     def get_sequence(self,genome,stranded=True):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_MaskedArray); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_counts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_counts));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_counts));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask), __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_14 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject*)&PyBool_Type)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
    __Pyx_INCREF(((PyObject*)&PyBool_Type));
    __Pyx_GIVEREF(((PyObject*)&PyBool_Type));
    PyTuple_SET_ITEM(__pyx_t_15, 0+1, ((PyObject*)&PyBool_Type));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mask, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_copy, __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2736
 *         return count_array
 * 
 *     def get_masked_counts(self,ga,stranded=True,copy=False):             # <<<<<<<<<<<<<<
 *         """Return counts covering `self` in dataset `gnd` as a masked array, in transcript
 *         coordinates. Positions masked by :py:meth:`SegmentChain.add_mask`
 */

  /* function exit code */
  __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_8);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_masked_counts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_counts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_mask.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_counts);
  __Pyx_XDECREF((PyObject *)__pyx_v_mask);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2775
 *         return MaskedArray(counts,mask=mask.astype(bool),copy=copy)
 * 
 *     def get_sequence(self,genome,stranded=True):             # <<<<<<<<<<<<<<
 *         """Return spliced genomic sequence of |SegmentChain| as a string
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_91get_sequence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_90get_sequence[] = "SegmentChain.get_sequence(self, genome, stranded=True)\nReturn spliced genomic sequence of |SegmentChain| as a string\n        \n        Parameters\n        ----------\n        genome : dict or :class:`twobitreader.TwoBitFile`\n            Dictionary mapping chromosome names to sequences.\n            Sequences may be strings, string-like, or :py:class:`Bio.Seq.SeqRecord` objects\n       \n        stranded : bool\n            If `True` and the |SegmentChain| is on the minus strand,\n            sequence will be reverse-complemented (Default: True)\n            \n            \n        Returns\n        -------\n        str\n            Nucleotide sequence of the |SegmentChain| extracted from `genome`\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_91get_sequence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_genome = 0;
  PyObject *__pyx_v_stranded = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_sequence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_genome,&__pyx_n_s_stranded,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_True);
    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_genome)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stranded);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_sequence") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __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_genome = values[0];
    __pyx_v_stranded = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_sequence", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_90get_sequence(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_genome, __pyx_v_stranded);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_90get_sequence(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_genome, PyObject *__pyx_v_stranded) {
  PyObject *__pyx_v_ltmp = 0;
  PyObject *__pyx_v_stmp = 0;
  PyObject *__pyx_v_chromseq = NULL;
  PyObject *__pyx_v_X = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  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)(PyObject *);
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_sequence", 0);

  /* "plastid/genomics/roitools.pyx":2798
 *             str stmp
 * 
 *         if len(self._segments) == 0:             # <<<<<<<<<<<<<<
 *             warnings.warn("%s is a zero-length SegmentChain. Returning empty sequence." % self.get_name(),DataWarning)
 *             return ""
 */
  __pyx_t_1 = __pyx_v_self->_segments;
  __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 = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((__pyx_t_2 == 0) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2799
 * 
 *         if len(self._segments) == 0:
 *             warnings.warn("%s is a zero-length SegmentChain. Returning empty sequence." % self.get_name(),DataWarning)             # <<<<<<<<<<<<<<
 *             return ""
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_is_a_zero_length_SegmentChain_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DataWarning); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    __pyx_t_2 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_2 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_2, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_2, __pyx_t_4);
    __pyx_t_6 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":2800
 *         if len(self._segments) == 0:
 *             warnings.warn("%s is a zero-length SegmentChain. Returning empty sequence." % self.get_name(),DataWarning)
 *             return ""             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__16);
    __pyx_r = __pyx_kp_s__16;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":2798
 *             str stmp
 * 
 *         if len(self._segments) == 0:             # <<<<<<<<<<<<<<
 *             warnings.warn("%s is a zero-length SegmentChain. Returning empty sequence." % self.get_name(),DataWarning)
 *             return ""
 */
  }

  /* "plastid/genomics/roitools.pyx":2803
 * 
 *         else:
 *             chromseq = genome[self.spanning_segment.chrom]             # <<<<<<<<<<<<<<
 *             ltmp = [chromseq[X.start:X.end] for X in self]
 *             stmp = "".join([str(X.seq) if isinstance(X,SeqRecord) else X for X in ltmp])
 */
  /*else*/ {
    __pyx_t_1 = PyObject_GetItem(__pyx_v_genome, __pyx_v_self->spanning_segment->chrom); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_chromseq = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":2804
 *         else:
 *             chromseq = genome[self.spanning_segment.chrom]
 *             ltmp = [chromseq[X.start:X.end] for X in self]             # <<<<<<<<<<<<<<
 *             stmp = "".join([str(X.seq) if isinstance(X,SeqRecord) else X for X in ltmp])
 * 
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self))) {
      __pyx_t_5 = ((PyObject *)__pyx_v_self); __Pyx_INCREF(__pyx_t_5); __pyx_t_2 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_2 = -1; __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_9)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_8); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_5, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        } else {
          if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_8); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_8 = PySequence_ITEM(__pyx_t_5, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          #endif
        }
      } else {
        __pyx_t_8 = __pyx_t_9(__pyx_t_5);
        if (unlikely(!__pyx_t_8)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_8);
      }
      __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_start); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_chromseq, 0, 0, &__pyx_t_8, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_ltmp = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":2805
 *             chromseq = genome[self.spanning_segment.chrom]
 *             ltmp = [chromseq[X.start:X.end] for X in self]
 *             stmp = "".join([str(X.seq) if isinstance(X,SeqRecord) else X for X in ltmp])             # <<<<<<<<<<<<<<
 * 
 *             if self.strand == "-"  and stranded == True:
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __pyx_v_ltmp; __Pyx_INCREF(__pyx_t_5); __pyx_t_2 = 0;
    for (;;) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_2); __Pyx_INCREF(__pyx_t_6); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_SeqRecord); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_IsInstance(__pyx_v_X, __pyx_t_4); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((__pyx_t_3 != 0)) {
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_seq); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_6 = __pyx_t_4;
        __pyx_t_4 = 0;
      } else {
        __Pyx_INCREF(__pyx_v_X);
        __pyx_t_6 = __pyx_v_X;
      }
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyString_Join(__pyx_kp_s__16, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_stmp = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":2807
 *             stmp = "".join([str(X.seq) if isinstance(X,SeqRecord) else X for X in ltmp])
 * 
 *             if self.strand == "-"  and stranded == True:             # <<<<<<<<<<<<<<
 *                 stmp = str(Seq(stmp,generic_dna).reverse_complement())
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_strand); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_kp_s__3, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_10) {
    } else {
      __pyx_t_3 = __pyx_t_10;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_stranded, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = __pyx_t_10;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_3) {

      /* "plastid/genomics/roitools.pyx":2808
 * 
 *             if self.strand == "-"  and stranded == True:
 *                 stmp = str(Seq(stmp,generic_dna).reverse_complement())             # <<<<<<<<<<<<<<
 * 
 *         return stmp
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_Seq); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_generic_dna); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = NULL;
      __pyx_t_2 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_2 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(__pyx_v_stmp);
      __Pyx_GIVEREF(__pyx_v_stmp);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_2, __pyx_v_stmp);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_2, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_reverse_complement); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_1) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_5);
      __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 = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF_SET(__pyx_v_stmp, ((PyObject*)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "plastid/genomics/roitools.pyx":2807
 *             stmp = "".join([str(X.seq) if isinstance(X,SeqRecord) else X for X in ltmp])
 * 
 *             if self.strand == "-"  and stranded == True:             # <<<<<<<<<<<<<<
 *                 stmp = str(Seq(stmp,generic_dna).reverse_complement())
 * 
 */
    }
  }

  /* "plastid/genomics/roitools.pyx":2810
 *                 stmp = str(Seq(stmp,generic_dna).reverse_complement())
 * 
 *         return stmp             # <<<<<<<<<<<<<<
 * 
 *     def get_fasta(self,genome,stranded=True):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_stmp);
  __pyx_r = __pyx_v_stmp;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2775
 *         return MaskedArray(counts,mask=mask.astype(bool),copy=copy)
 * 
 *     def get_sequence(self,genome,stranded=True):             # <<<<<<<<<<<<<<
 *         """Return spliced genomic sequence of |SegmentChain| as a string
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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("plastid.genomics.roitools.SegmentChain.get_sequence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ltmp);
  __Pyx_XDECREF(__pyx_v_stmp);
  __Pyx_XDECREF(__pyx_v_chromseq);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2812
 *         return stmp
 * 
 *     def get_fasta(self,genome,stranded=True):             # <<<<<<<<<<<<<<
 *         """Formats sequence of SegmentChain as FASTA output
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_93get_fasta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_92get_fasta[] = "SegmentChain.get_fasta(self, genome, stranded=True)\nFormats sequence of SegmentChain as FASTA output\n        \n        Parameters\n        ----------\n        genome : dict or :class:`twobitreader.TwoBitFile`\n            Dictionary mapping chromosome names to sequences.\n            Sequences may be strings, string-like, or :py:class:`Bio.Seq.SeqRecord` objects\n       \n        stranded : bool\n            If `True` and the |SegmentChain| is on the minus strand,\n            sequence will be reverse-complemented (Default: True)\n\n            \n        Returns\n        -------\n        str\n            FASTA-formatted seuqence of |SegmentChain| extracted from `genome`\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_93get_fasta(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_genome = 0;
  PyObject *__pyx_v_stranded = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_fasta (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_genome,&__pyx_n_s_stranded,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_True);
    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_genome)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stranded);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_fasta") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __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_genome = values[0];
    __pyx_v_stranded = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_fasta", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.get_fasta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_92get_fasta(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_genome, __pyx_v_stranded);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_92get_fasta(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_genome, PyObject *__pyx_v_stranded) {
  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("get_fasta", 0);

  /* "plastid/genomics/roitools.pyx":2831
 *             FASTA-formatted seuqence of |SegmentChain| extracted from `genome`
 *         """
 *         return ">%s\n%s\n" % (self.get_name(),self.get_sequence(genome,stranded=stranded))             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_sequence); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __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 = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_genome);
  __Pyx_GIVEREF(__pyx_v_genome);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_genome);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_stranded, __pyx_v_stranded) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_s_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2812
 *         return stmp
 * 
 *     def get_fasta(self,genome,stranded=True):             # <<<<<<<<<<<<<<
 *         """Formats sequence of SegmentChain as FASTA output
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.SegmentChain.get_fasta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2834
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a string formatted by :py:meth:`SegmentChain.__str__`:
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_95from_str(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_94from_str[] = "SegmentChain.from_str(str inp)\nCreate a |SegmentChain| from a string formatted by :py:meth:`SegmentChain.__str__`:\n           \n            `chrom:start-end^start-end(strand)`\n           \n        where '^' indicates a splice junction between regions specified\n        by `start` and `end` and `strand` is '+', '-', or '.'. Coordinates are\n        0-indexed and half-open.\n\n\n        Parameters\n        ----------\n        inp : str\n\t\t\tString formatted in manner of :py:meth:`SegmentChain.__str__`\n          \n          \n        Returns\n        -------\n        |SegmentChain|\n        ";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_12SegmentChain_95from_str = {"from_str", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_95from_str, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_94from_str};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_95from_str(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_inp = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_str (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_inp,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_inp)) != 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, "from_str") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __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_inp = ((PyObject*)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_str", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.from_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_inp), (&PyString_Type), 1, "inp", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_94from_str(__pyx_v_inp);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_94from_str(PyObject *__pyx_v_inp) {
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_middle = 0;
  PyObject *__pyx_v_strand = 0;
  PyObject *__pyx_v_sstart = 0;
  PyObject *__pyx_v_send = 0;
  PyObject *__pyx_v_piece = 0;
  PyObject *__pyx_v_segs = 0;
  long __pyx_v_start;
  long __pyx_v_end;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  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)(PyObject *);
  Py_ssize_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  long __pyx_t_14;
  int __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_str", 0);

  /* "plastid/genomics/roitools.pyx":2859
 *             long start, end
 * 
 *         if inp in ("na","nan","None:(None)","None","none",None) or isinstance(inp,float) and numpy.isnan(inp):             # <<<<<<<<<<<<<<
 *             return SegmentChain()
 *         else:
 */
  __Pyx_INCREF(__pyx_v_inp);
  __pyx_t_2 = __pyx_v_inp;
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_na, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_nan, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_kp_s_None_None, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_None, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_5 != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_none, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_2, Py_None, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __pyx_t_5;
  __pyx_L6_bool_binop_done:;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = (__pyx_t_3 != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = PyFloat_Check(__pyx_v_inp); 
  __pyx_t_3 = (__pyx_t_5 != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_isnan); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_inp); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    __Pyx_INCREF(__pyx_v_inp);
    __Pyx_GIVEREF(__pyx_v_inp);
    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_inp);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":2860
 * 
 *         if inp in ("na","nan","None:(None)","None","none",None) or isinstance(inp,float) and numpy.isnan(inp):
 *             return SegmentChain()             # <<<<<<<<<<<<<<
 *         else:
 *             chrom,middle,strand = ivcpat.search(inp).groups()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":2859
 *             long start, end
 * 
 *         if inp in ("na","nan","None:(None)","None","none",None) or isinstance(inp,float) and numpy.isnan(inp):             # <<<<<<<<<<<<<<
 *             return SegmentChain()
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":2862
 *             return SegmentChain()
 *         else:
 *             chrom,middle,strand = ivcpat.search(inp).groups()             # <<<<<<<<<<<<<<
 *             segs = []
 *             for piece in middle.split("^"):
 */
  /*else*/ {
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_ivcpat); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_search); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_inp); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_INCREF(__pyx_v_inp);
      __Pyx_GIVEREF(__pyx_v_inp);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_inp);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_groups); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_8) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 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 != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __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); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_10);
      #else
      __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext;
      index = 0; __pyx_t_7 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L13_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      index = 1; __pyx_t_8 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L13_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      index = 2; __pyx_t_10 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_10)) goto __pyx_L13_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_10);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L14_unpacking_done;
      __pyx_L13_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L14_unpacking_done:;
    }
    if (!(likely(PyString_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(PyString_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_8)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(PyString_CheckExact(__pyx_t_10))||((__pyx_t_10) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_10)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_chrom = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_v_middle = ((PyObject*)__pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_v_strand = ((PyObject*)__pyx_t_10);
    __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":2863
 *         else:
 *             chrom,middle,strand = ivcpat.search(inp).groups()
 *             segs = []             # <<<<<<<<<<<<<<
 *             for piece in middle.split("^"):
 *                 sstart,send = piece.split("-")
 */
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_segs = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":2864
 *             chrom,middle,strand = ivcpat.search(inp).groups()
 *             segs = []
 *             for piece in middle.split("^"):             # <<<<<<<<<<<<<<
 *                 sstart,send = piece.split("-")
 *                 start = long(sstart)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_middle, __pyx_n_s_split); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (likely(PyList_CheckExact(__pyx_t_10)) || PyTuple_CheckExact(__pyx_t_10)) {
      __pyx_t_6 = __pyx_t_10; __Pyx_INCREF(__pyx_t_6); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_13 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    for (;;) {
      if (likely(!__pyx_t_13)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_10 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          #endif
        } else {
          if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          #endif
        }
      } else {
        __pyx_t_10 = __pyx_t_13(__pyx_t_6);
        if (unlikely(!__pyx_t_10)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_10);
      }
      if (!(likely(PyString_CheckExact(__pyx_t_10))||((__pyx_t_10) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_10)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF_SET(__pyx_v_piece, ((PyObject*)__pyx_t_10));
      __pyx_t_10 = 0;

      /* "plastid/genomics/roitools.pyx":2865
 *             segs = []
 *             for piece in middle.split("^"):
 *                 sstart,send = piece.split("-")             # <<<<<<<<<<<<<<
 *                 start = long(sstart)
 *                 end = long(send)
 */
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_piece, __pyx_n_s_split); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
        PyObject* sequence = __pyx_t_8;
        #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 = 2865; __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_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_10 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_10 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_10)) goto __pyx_L17_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        index = 1; __pyx_t_7 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L17_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L18_unpacking_done;
        __pyx_L17_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L18_unpacking_done:;
      }
      if (!(likely(PyString_CheckExact(__pyx_t_10))||((__pyx_t_10) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_10)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!(likely(PyString_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF_SET(__pyx_v_sstart, ((PyObject*)__pyx_t_10));
      __pyx_t_10 = 0;
      __Pyx_XDECREF_SET(__pyx_v_send, ((PyObject*)__pyx_t_7));
      __pyx_t_7 = 0;

      /* "plastid/genomics/roitools.pyx":2866
 *             for piece in middle.split("^"):
 *                 sstart,send = piece.split("-")
 *                 start = long(sstart)             # <<<<<<<<<<<<<<
 *                 end = long(send)
 *                 segs.append(GenomicSegment(chrom,start,end,strand))
 */
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_sstart);
      __Pyx_GIVEREF(__pyx_v_sstart);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_sstart);
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)(&PyLong_Type)), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_14 = __Pyx_PyInt_As_long(__pyx_t_7); if (unlikely((__pyx_t_14 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_start = __pyx_t_14;

      /* "plastid/genomics/roitools.pyx":2867
 *                 sstart,send = piece.split("-")
 *                 start = long(sstart)
 *                 end = long(send)             # <<<<<<<<<<<<<<
 *                 segs.append(GenomicSegment(chrom,start,end,strand))
 *             return SegmentChain(*segs)
 */
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_send);
      __Pyx_GIVEREF(__pyx_v_send);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_send);
      __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)(&PyLong_Type)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_14 = __Pyx_PyInt_As_long(__pyx_t_8); if (unlikely((__pyx_t_14 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_end = __pyx_t_14;

      /* "plastid/genomics/roitools.pyx":2868
 *                 start = long(sstart)
 *                 end = long(send)
 *                 segs.append(GenomicSegment(chrom,start,end,strand))             # <<<<<<<<<<<<<<
 *             return SegmentChain(*segs)
 * 
 */
      __pyx_t_8 = __Pyx_PyInt_From_long(__pyx_v_start); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __Pyx_PyInt_From_long(__pyx_v_end); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_v_chrom);
      __Pyx_GIVEREF(__pyx_v_chrom);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_chrom);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_7);
      __Pyx_INCREF(__pyx_v_strand);
      __Pyx_GIVEREF(__pyx_v_strand);
      PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_v_strand);
      __pyx_t_8 = 0;
      __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_15 = __Pyx_PyList_Append(__pyx_v_segs, __pyx_t_7); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "plastid/genomics/roitools.pyx":2864
 *             chrom,middle,strand = ivcpat.search(inp).groups()
 *             segs = []
 *             for piece in middle.split("^"):             # <<<<<<<<<<<<<<
 *                 sstart,send = piece.split("-")
 *                 start = long(sstart)
 */
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":2869
 *                 end = long(send)
 *                 segs.append(GenomicSegment(chrom,start,end,strand))
 *             return SegmentChain(*segs)             # <<<<<<<<<<<<<<
 * 
 *     # TODO: optimize
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = PySequence_Tuple(__pyx_v_segs); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":2834
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a string formatted by :py:meth:`SegmentChain.__str__`:
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __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_AddTraceback("plastid.genomics.roitools.SegmentChain.from_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_middle);
  __Pyx_XDECREF(__pyx_v_strand);
  __Pyx_XDECREF(__pyx_v_sstart);
  __Pyx_XDECREF(__pyx_v_send);
  __Pyx_XDECREF(__pyx_v_piece);
  __Pyx_XDECREF(__pyx_v_segs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":2873
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line, extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `BED`_ file.
 *         The `BED`_ line may contain 4 to 12 columns, per the specification.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_97from_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_96from_bed[] = "SegmentChain.from_bed(str line, extra_columns=0)\nCreate a |SegmentChain| from a line from a `BED`_ file.\n        The `BED`_ line may contain 4 to 12 columns, per the specification.\n        These will be auto-detected and parsed appropriately.\n        \n        See the `UCSC file format faq <http://genome.ucsc.edu/FAQ/FAQformat.html>`_\n        for more details.\n\n        Parameters\n        ----------\n        line\n            Line from a `BED`_ file, containing 4 or more columns\n\n        extra_columns: int or list optional\n            Extra, non-BED columns in :term:`BED X+Y`_ format file corresponding to feature\n            attributes. This is common in `ENCODE`_-specific `BED`_ variants.\n            \n            if `extra-columns` is:\n            \n              - an :class:`int`: it is taken to be the\n                number of attribute columns. Attributes will be stored in\n                the `attr` dictionary of the |SegmentChain|, under names like\n                `custom0`, `custom1`, ... , `customN`.\n\n              - a :class:`list` of :class:`str`, it is taken to be the names\n                of the attribute columns, in order, from left to right in the file.\n                In this case, attributes in extra columns will be stored under\n                there respective names in the `attr` dict.\n\n              - a :class:`list` of :class:`tuple`, each tuple is taken\n                to be a pair of `(attribute_name, formatter_func)`. In this case,\n                the value of `attribute_name` in the `attr` dict of the |SegmentChain|\n                will be set to `formatter_func(column_value)`.\n            \n            (Default: 0)\n\n        Returns\n        -------\n        |SegmentChain|\n        ";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_12SegmentChain_97from_bed = {"from_bed", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_97from_bed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_96from_bed};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_97from_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_line = 0;
  PyObject *__pyx_v_extra_columns = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_bed (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_line,&__pyx_n_s_extra_columns,0};
    PyObject* values[2] = {0,0};
    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 (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_line)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_extra_columns);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __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_line = ((PyObject*)values[0]);
    __pyx_v_extra_columns = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_bed", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.from_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_line), (&PyString_Type), 1, "line", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_96from_bed(__pyx_v_line, __pyx_v_extra_columns);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_96from_bed(PyObject *__pyx_v_line, PyObject *__pyx_v_extra_columns) {
  int __pyx_v_num_bed_columns;
  int __pyx_v_num_extra_columns;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_v_frags = 0;
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_column_formatters = NULL;
  PyObject *__pyx_v_types = NULL;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_chrom_start = NULL;
  PyObject *__pyx_v_chrom_end = NULL;
  PyObject *__pyx_v_strand = NULL;
  PyObject *__pyx_v_default_id = NULL;
  PyObject *__pyx_v_bed_columns = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_tup = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_default = NULL;
  PyObject *__pyx_v_func = NULL;
  PyObject *__pyx_v_name = NULL;
  PyObject *__pyx_v_formatter = NULL;
  PyObject *__pyx_v_num_frags = NULL;
  PyObject *__pyx_v_frag_sizes = NULL;
  PyObject *__pyx_v_frag_offsets = NULL;
  PyObject *__pyx_v_frag_start = NULL;
  PyObject *__pyx_v_frag_end = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_X = 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;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_bed", 0);

  /* "plastid/genomics/roitools.pyx":2916
 *             int num_bed_columns, num_extra_columns
 *             dict attr
 *             list frags = []             # <<<<<<<<<<<<<<
 *             list items = line.strip("\n").split("\t")
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_frags = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2917
 *             dict attr
 *             list frags = []
 *             list items = line.strip("\n").split("\t")             # <<<<<<<<<<<<<<
 * 
 *             #list column_formatters, frag_sizes, frag_offsets
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_line, __pyx_n_s_strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__27, NULL); 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__28, NULL); 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_items = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":2926
 *             #dict base_columns, attr
 * 
 *         if isinstance(extra_columns,int):             # <<<<<<<<<<<<<<
 *             if extra_columns < 0:
 *                 raise ValueError("Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.")
 */
  __pyx_t_3 = PyInt_Check(__pyx_v_extra_columns); 
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":2927
 * 
 *         if isinstance(extra_columns,int):
 *             if extra_columns < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.")
 *             num_extra_columns = extra_columns
 */
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_extra_columns, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_4) {

      /* "plastid/genomics/roitools.pyx":2928
 *         if isinstance(extra_columns,int):
 *             if extra_columns < 0:
 *                 raise ValueError("Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.")             # <<<<<<<<<<<<<<
 *             num_extra_columns = extra_columns
 *             column_formatters = [("custom%s" % X,str) for X in range(extra_columns)]
 */
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":2927
 * 
 *         if isinstance(extra_columns,int):
 *             if extra_columns < 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.")
 *             num_extra_columns = extra_columns
 */
    }

    /* "plastid/genomics/roitools.pyx":2929
 *             if extra_columns < 0:
 *                 raise ValueError("Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.")
 *             num_extra_columns = extra_columns             # <<<<<<<<<<<<<<
 *             column_formatters = [("custom%s" % X,str) for X in range(extra_columns)]
 *         elif isinstance(extra_columns,list):
 */
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_extra_columns); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_num_extra_columns = __pyx_t_5;

    /* "plastid/genomics/roitools.pyx":2930
 *                 raise ValueError("Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.")
 *             num_extra_columns = extra_columns
 *             column_formatters = [("custom%s" % X,str) for X in range(extra_columns)]             # <<<<<<<<<<<<<<
 *         elif isinstance(extra_columns,list):
 *             num_extra_columns = len(extra_columns)
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __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 = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_extra_columns);
    __Pyx_GIVEREF(__pyx_v_extra_columns);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_extra_columns);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
      __pyx_t_1 = __pyx_t_6; __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_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_8(__pyx_t_1);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_custom_s, __pyx_v_X); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
      __Pyx_INCREF(((PyObject *)(&PyString_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
      PyTuple_SET_ITEM(__pyx_t_9, 1, ((PyObject *)(&PyString_Type)));
      __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_column_formatters = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":2926
 *             #dict base_columns, attr
 * 
 *         if isinstance(extra_columns,int):             # <<<<<<<<<<<<<<
 *             if extra_columns < 0:
 *                 raise ValueError("Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.")
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":2931
 *             num_extra_columns = extra_columns
 *             column_formatters = [("custom%s" % X,str) for X in range(extra_columns)]
 *         elif isinstance(extra_columns,list):             # <<<<<<<<<<<<<<
 *             num_extra_columns = len(extra_columns)
 *             types = set([type(X) for X in extra_columns])
 */
  __pyx_t_4 = PyList_Check(__pyx_v_extra_columns); 
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2932
 *             column_formatters = [("custom%s" % X,str) for X in range(extra_columns)]
 *         elif isinstance(extra_columns,list):
 *             num_extra_columns = len(extra_columns)             # <<<<<<<<<<<<<<
 *             types = set([type(X) for X in extra_columns])
 *             if len(types) > 1:
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_extra_columns); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_num_extra_columns = __pyx_t_7;

    /* "plastid/genomics/roitools.pyx":2933
 *         elif isinstance(extra_columns,list):
 *             num_extra_columns = len(extra_columns)
 *             types = set([type(X) for X in extra_columns])             # <<<<<<<<<<<<<<
 *             if len(types) > 1:
 *                 raise ValueError("List of `extra_columns` contains mixed types. Cannot parse.")
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (likely(PyList_CheckExact(__pyx_v_extra_columns)) || PyTuple_CheckExact(__pyx_v_extra_columns)) {
      __pyx_t_1 = __pyx_v_extra_columns; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_extra_columns); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_8(__pyx_t_1);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_9);
      __pyx_t_9 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)((PyObject *)Py_TYPE(__pyx_v_X))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PySet_New(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_types = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":2934
 *             num_extra_columns = len(extra_columns)
 *             types = set([type(X) for X in extra_columns])
 *             if len(types) > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError("List of `extra_columns` contains mixed types. Cannot parse.")
 *             elif str in types:
 */
    __pyx_t_7 = PySet_GET_SIZE(__pyx_v_types); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((__pyx_t_7 > 1) != 0);
    if (__pyx_t_3) {

      /* "plastid/genomics/roitools.pyx":2935
 *             types = set([type(X) for X in extra_columns])
 *             if len(types) > 1:
 *                 raise ValueError("List of `extra_columns` contains mixed types. Cannot parse.")             # <<<<<<<<<<<<<<
 *             elif str in types:
 *                 column_formatters = [(X,str) for X in extra_columns]
 */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2935; __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 = 2935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":2934
 *             num_extra_columns = len(extra_columns)
 *             types = set([type(X) for X in extra_columns])
 *             if len(types) > 1:             # <<<<<<<<<<<<<<
 *                 raise ValueError("List of `extra_columns` contains mixed types. Cannot parse.")
 *             elif str in types:
 */
    }

    /* "plastid/genomics/roitools.pyx":2936
 *             if len(types) > 1:
 *                 raise ValueError("List of `extra_columns` contains mixed types. Cannot parse.")
 *             elif str in types:             # <<<<<<<<<<<<<<
 *                 column_formatters = [(X,str) for X in extra_columns]
 *             elif tuple in types:
 */
    __pyx_t_3 = (__Pyx_PySequence_ContainsTF(((PyObject *)(&PyString_Type)), __pyx_v_types, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = (__pyx_t_3 != 0);
    if (__pyx_t_4) {

      /* "plastid/genomics/roitools.pyx":2937
 *                 raise ValueError("List of `extra_columns` contains mixed types. Cannot parse.")
 *             elif str in types:
 *                 column_formatters = [(X,str) for X in extra_columns]             # <<<<<<<<<<<<<<
 *             elif tuple in types:
 *                 if all([len(X) == 2 for X in extra_columns]) == False:
 */
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (likely(PyList_CheckExact(__pyx_v_extra_columns)) || PyTuple_CheckExact(__pyx_v_extra_columns)) {
        __pyx_t_2 = __pyx_v_extra_columns; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_extra_columns); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      for (;;) {
        if (likely(!__pyx_t_8)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_9 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_9 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          } else {
            if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_9 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          }
        } else {
          __pyx_t_9 = __pyx_t_8(__pyx_t_2);
          if (unlikely(!__pyx_t_9)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_v_X);
        __Pyx_GIVEREF(__pyx_v_X);
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_X);
        __Pyx_INCREF(((PyObject *)(&PyString_Type)));
        __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
        PyTuple_SET_ITEM(__pyx_t_9, 1, ((PyObject *)(&PyString_Type)));
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_column_formatters = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "plastid/genomics/roitools.pyx":2936
 *             if len(types) > 1:
 *                 raise ValueError("List of `extra_columns` contains mixed types. Cannot parse.")
 *             elif str in types:             # <<<<<<<<<<<<<<
 *                 column_formatters = [(X,str) for X in extra_columns]
 *             elif tuple in types:
 */
      goto __pyx_L9;
    }

    /* "plastid/genomics/roitools.pyx":2938
 *             elif str in types:
 *                 column_formatters = [(X,str) for X in extra_columns]
 *             elif tuple in types:             # <<<<<<<<<<<<<<
 *                 if all([len(X) == 2 for X in extra_columns]) == False:
 *                     raise ValueError("Cannot make SegmentChain from BED input: if a list, extra_columns must be a list of tuples of (column_name,formatter_func)")
 */
    __pyx_t_4 = (__Pyx_PySequence_ContainsTF(((PyObject *)(&PyTuple_Type)), __pyx_v_types, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = (__pyx_t_4 != 0);
    if (__pyx_t_3) {

      /* "plastid/genomics/roitools.pyx":2939
 *                 column_formatters = [(X,str) for X in extra_columns]
 *             elif tuple in types:
 *                 if all([len(X) == 2 for X in extra_columns]) == False:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Cannot make SegmentChain from BED input: if a list, extra_columns must be a list of tuples of (column_name,formatter_func)")
 *                 column_formatters = extra_columns
 */
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (likely(PyList_CheckExact(__pyx_v_extra_columns)) || PyTuple_CheckExact(__pyx_v_extra_columns)) {
        __pyx_t_2 = __pyx_v_extra_columns; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_extra_columns); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      for (;;) {
        if (likely(!__pyx_t_8)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_9 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_9 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          } else {
            if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_9 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          }
        } else {
          __pyx_t_9 = __pyx_t_8(__pyx_t_2);
          if (unlikely(!__pyx_t_9)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, 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_9);
        }
        __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_10 = PyObject_Length(__pyx_v_X); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = __Pyx_PyBool_FromLong((__pyx_t_10 == 2)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __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 = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_all, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __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_RichCompare(__pyx_t_1, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __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 = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_3) {

        /* "plastid/genomics/roitools.pyx":2940
 *             elif tuple in types:
 *                 if all([len(X) == 2 for X in extra_columns]) == False:
 *                     raise ValueError("Cannot make SegmentChain from BED input: if a list, extra_columns must be a list of tuples of (column_name,formatter_func)")             # <<<<<<<<<<<<<<
 *                 column_formatters = extra_columns
 *         else:
 */
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "plastid/genomics/roitools.pyx":2939
 *                 column_formatters = [(X,str) for X in extra_columns]
 *             elif tuple in types:
 *                 if all([len(X) == 2 for X in extra_columns]) == False:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Cannot make SegmentChain from BED input: if a list, extra_columns must be a list of tuples of (column_name,formatter_func)")
 *                 column_formatters = extra_columns
 */
      }

      /* "plastid/genomics/roitools.pyx":2941
 *                 if all([len(X) == 2 for X in extra_columns]) == False:
 *                     raise ValueError("Cannot make SegmentChain from BED input: if a list, extra_columns must be a list of tuples of (column_name,formatter_func)")
 *                 column_formatters = extra_columns             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("Cannot make SegmentChain from BED input: extra_columns must be an int or list. Got a %s" % type(extra_columns))
 */
      __Pyx_INCREF(__pyx_v_extra_columns);
      __pyx_v_column_formatters = __pyx_v_extra_columns;

      /* "plastid/genomics/roitools.pyx":2938
 *             elif str in types:
 *                 column_formatters = [(X,str) for X in extra_columns]
 *             elif tuple in types:             # <<<<<<<<<<<<<<
 *                 if all([len(X) == 2 for X in extra_columns]) == False:
 *                     raise ValueError("Cannot make SegmentChain from BED input: if a list, extra_columns must be a list of tuples of (column_name,formatter_func)")
 */
    }
    __pyx_L9:;

    /* "plastid/genomics/roitools.pyx":2931
 *             num_extra_columns = extra_columns
 *             column_formatters = [("custom%s" % X,str) for X in range(extra_columns)]
 *         elif isinstance(extra_columns,list):             # <<<<<<<<<<<<<<
 *             num_extra_columns = len(extra_columns)
 *             types = set([type(X) for X in extra_columns])
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":2943
 *                 column_formatters = extra_columns
 *         else:
 *             raise TypeError("Cannot make SegmentChain from BED input: extra_columns must be an int or list. Got a %s" % type(extra_columns))             # <<<<<<<<<<<<<<
 * 
 *         num_bed_columns = len(items) - num_extra_columns
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_make_SegmentChain_from_BE_3, ((PyObject *)Py_TYPE(__pyx_v_extra_columns))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2943; __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 = 2943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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 = 2943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":2945
 *             raise TypeError("Cannot make SegmentChain from BED input: extra_columns must be an int or list. Got a %s" % type(extra_columns))
 * 
 *         num_bed_columns = len(items) - num_extra_columns             # <<<<<<<<<<<<<<
 *         if num_bed_columns < 3:
 *             raise ValueError("BED format requires at least 3 columns. Found only %s." % num_bed_columns)
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = PyList_GET_SIZE(__pyx_v_items); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_num_bed_columns = (__pyx_t_7 - __pyx_v_num_extra_columns);

  /* "plastid/genomics/roitools.pyx":2946
 * 
 *         num_bed_columns = len(items) - num_extra_columns
 *         if num_bed_columns < 3:             # <<<<<<<<<<<<<<
 *             raise ValueError("BED format requires at least 3 columns. Found only %s." % num_bed_columns)
 * 
 */
  __pyx_t_3 = ((__pyx_v_num_bed_columns < 3) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2947
 *         num_bed_columns = len(items) - num_extra_columns
 *         if num_bed_columns < 3:
 *             raise ValueError("BED format requires at least 3 columns. Found only %s." % num_bed_columns)             # <<<<<<<<<<<<<<
 * 
 *         chrom         = items[0]
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_num_bed_columns); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_BED_format_requires_at_least_3_c, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2947; __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 = 2947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__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 = 2947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":2946
 * 
 *         num_bed_columns = len(items) - num_extra_columns
 *         if num_bed_columns < 3:             # <<<<<<<<<<<<<<
 *             raise ValueError("BED format requires at least 3 columns. Found only %s." % num_bed_columns)
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2949
 *             raise ValueError("BED format requires at least 3 columns. Found only %s." % num_bed_columns)
 * 
 *         chrom         = items[0]             # <<<<<<<<<<<<<<
 *         chrom_start   = long(items[1])
 *         chrom_end     = long(items[2])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2949; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_chrom = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2950
 * 
 *         chrom         = items[0]
 *         chrom_start   = long(items[1])             # <<<<<<<<<<<<<<
 *         chrom_end     = long(items[2])
 *         strand = "." if num_bed_columns < 6 else items[5]
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __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 = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyLong_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrom_start = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2951
 *         chrom         = items[0]
 *         chrom_start   = long(items[1])
 *         chrom_end     = long(items[2])             # <<<<<<<<<<<<<<
 *         strand = "." if num_bed_columns < 6 else items[5]
 * 
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2951; __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 = 2951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyLong_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_chrom_end = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2952
 *         chrom_start   = long(items[1])
 *         chrom_end     = long(items[2])
 *         strand = "." if num_bed_columns < 6 else items[5]             # <<<<<<<<<<<<<<
 * 
 *         default_id  = "%s:%s-%s(%s)" % (chrom,chrom_start,chrom_end,strand)
 */
  if (((__pyx_v_num_bed_columns < 6) != 0)) {
    __Pyx_INCREF(__pyx_kp_s__4);
    __pyx_t_1 = __pyx_kp_s__4;
  } else {
    if (unlikely(__pyx_v_items == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 5, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_v_strand = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2954
 *         strand = "." if num_bed_columns < 6 else items[5]
 * 
 *         default_id  = "%s:%s-%s(%s)" % (chrom,chrom_start,chrom_end,strand)             # <<<<<<<<<<<<<<
 * 
 *         # dict mapping optional bed column to tuple of (Name,default value)
 */
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_v_chrom);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_chrom);
  __Pyx_INCREF(__pyx_v_chrom_start);
  __Pyx_GIVEREF(__pyx_v_chrom_start);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_chrom_start);
  __Pyx_INCREF(__pyx_v_chrom_end);
  __Pyx_GIVEREF(__pyx_v_chrom_end);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_chrom_end);
  __Pyx_INCREF(__pyx_v_strand);
  __Pyx_GIVEREF(__pyx_v_strand);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_strand);
  __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_default_id = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":2958
 *         # dict mapping optional bed column to tuple of (Name,default value)
 *         # these values are used if any optional columns 4-12 are ommited
 *         bed_columns = { 3 :  ("ID",         default_id,    str),             # <<<<<<<<<<<<<<
 *                         4 :  ("score",      numpy.nan,     float),
 *                         #5 :  ("strand",    ".", strand),
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __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 = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_ID);
  __Pyx_GIVEREF(__pyx_n_s_ID);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ID);
  __Pyx_INCREF(__pyx_v_default_id);
  __Pyx_GIVEREF(__pyx_v_default_id);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_default_id);
  __Pyx_INCREF(((PyObject *)(&PyString_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)(&PyString_Type)));
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_3, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2959
 *         # these values are used if any optional columns 4-12 are ommited
 *         bed_columns = { 3 :  ("ID",         default_id,    str),
 *                         4 :  ("score",      numpy.nan,     float),             # <<<<<<<<<<<<<<
 *                         #5 :  ("strand",    ".", strand),
 *                         6 :  ("thickstart", None,          int),
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_nan); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__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 = 2959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_score);
  __Pyx_GIVEREF(__pyx_n_s_score);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_score);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)(&PyFloat_Type)));
  __pyx_t_9 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_4, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2961
 *                         4 :  ("score",      numpy.nan,     float),
 *                         #5 :  ("strand",    ".", strand),
 *                         6 :  ("thickstart", None,          int),             # <<<<<<<<<<<<<<
 *                         7 :  ("thickend",   None,          int),
 *                         8 :  ("color",      "0,0,0",       str),
 */
  __pyx_t_1 = PyTuple_New(3); 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_INCREF(__pyx_n_s_thickstart);
  __Pyx_GIVEREF(__pyx_n_s_thickstart);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_thickstart);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_1, 1, Py_None);
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)(&PyInt_Type)));
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_6, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2962
 *                         #5 :  ("strand",    ".", strand),
 *                         6 :  ("thickstart", None,          int),
 *                         7 :  ("thickend",   None,          int),             # <<<<<<<<<<<<<<
 *                         8 :  ("color",      "0,0,0",       str),
 *                         9 :  ("blocks",     "1",             int),
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_thickend);
  __Pyx_GIVEREF(__pyx_n_s_thickend);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_thickend);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_1, 1, Py_None);
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)(&PyInt_Type)));
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_7, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2963
 *                         6 :  ("thickstart", None,          int),
 *                         7 :  ("thickend",   None,          int),
 *                         8 :  ("color",      "0,0,0",       str),             # <<<<<<<<<<<<<<
 *                         9 :  ("blocks",     "1",             int),
 *                         10 : ("blocksizes", str(chrom_end - chrom_start),str),
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_color);
  __Pyx_GIVEREF(__pyx_n_s_color);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_color);
  __Pyx_INCREF(__pyx_kp_s_0_0_0);
  __Pyx_GIVEREF(__pyx_kp_s_0_0_0);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_s_0_0_0);
  __Pyx_INCREF(((PyObject *)(&PyString_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)(&PyString_Type)));
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_8, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2964
 *                         7 :  ("thickend",   None,          int),
 *                         8 :  ("color",      "0,0,0",       str),
 *                         9 :  ("blocks",     "1",             int),             # <<<<<<<<<<<<<<
 *                         10 : ("blocksizes", str(chrom_end - chrom_start),str),
 *                         11 : ("blockstarts","0",             str),
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_blocks);
  __Pyx_GIVEREF(__pyx_n_s_blocks);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_blocks);
  __Pyx_INCREF(__pyx_kp_s_1);
  __Pyx_GIVEREF(__pyx_kp_s_1);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_s_1);
  __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)(&PyInt_Type)));
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_9, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2965
 *                         8 :  ("color",      "0,0,0",       str),
 *                         9 :  ("blocks",     "1",             int),
 *                         10 : ("blocksizes", str(chrom_end - chrom_start),str),             # <<<<<<<<<<<<<<
 *                         11 : ("blockstarts","0",             str),
 *                       }
 */
  __pyx_t_1 = PyNumber_Subtract(__pyx_v_chrom_end, __pyx_v_chrom_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__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 = 2965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_n_s_blocksizes);
  __Pyx_GIVEREF(__pyx_n_s_blocksizes);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_blocksizes);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
  __Pyx_INCREF(((PyObject *)(&PyString_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
  PyTuple_SET_ITEM(__pyx_t_9, 2, ((PyObject *)(&PyString_Type)));
  __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_10, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "plastid/genomics/roitools.pyx":2966
 *                         9 :  ("blocks",     "1",             int),
 *                         10 : ("blocksizes", str(chrom_end - chrom_start),str),
 *                         11 : ("blockstarts","0",             str),             # <<<<<<<<<<<<<<
 *                       }
 * 
 */
  __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_n_s_blockstarts);
  __Pyx_GIVEREF(__pyx_n_s_blockstarts);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_n_s_blockstarts);
  __Pyx_INCREF(__pyx_kp_s_0);
  __Pyx_GIVEREF(__pyx_kp_s_0);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_kp_s_0);
  __Pyx_INCREF(((PyObject *)(&PyString_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
  PyTuple_SET_ITEM(__pyx_t_9, 2, ((PyObject *)(&PyString_Type)));
  if (PyDict_SetItem(__pyx_t_2, __pyx_int_11, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_bed_columns = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":2970
 * 
 *         # set attr defaults in case we're dealing with BED4-BED9 format
 *         attr = { KEY : DEFAULT for KEY,DEFAULT,_ in bed_columns.values() }             # <<<<<<<<<<<<<<
 * 
 *         # populate attr with real values from BED columns that are present
 */
  { /* enter inner scope */
    PyObject *__pyx_8genexpr5__pyx_v_KEY = NULL;
    PyObject *__pyx_8genexpr5__pyx_v_DEFAULT = NULL;
    CYTHON_UNUSED PyObject *__pyx_8genexpr5__pyx_v__ = NULL;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyDict_Values(__pyx_v_bed_columns); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
      __pyx_t_1 = __pyx_t_9; __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_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_8(__pyx_t_1);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_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 != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_11);
        __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 = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_6)) goto __pyx_L21_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_11 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L21_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 2; __pyx_t_12 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L21_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L22_unpacking_done;
        __pyx_L21_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
        __pyx_L22_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_KEY, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_DEFAULT, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v__, __pyx_t_12);
      __pyx_t_12 = 0;
      if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_8genexpr5__pyx_v_KEY, (PyObject*)__pyx_8genexpr5__pyx_v_DEFAULT))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_KEY);
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_DEFAULT);
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v__);
    goto __pyx_L23_exit_scope;
    __pyx_L18_error:;
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_KEY);
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_DEFAULT);
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v__);
    goto __pyx_L1_error;
    __pyx_L23_exit_scope:;
  } /* exit inner scope */
  __pyx_v_attr = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":2973
 * 
 *         # populate attr with real values from BED columns that are present
 *         for i, tup in sorted(bed_columns.items()):             # <<<<<<<<<<<<<<
 *             if num_bed_columns > i:
 *                 key     = tup[0]
 */
  __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_bed_columns); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = ((PyObject*)__pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_15 = PyList_Sort(__pyx_t_2); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(__pyx_t_2 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_9 = __pyx_t_2; __Pyx_INCREF(__pyx_t_9); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_9)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_2 = PySequence_ITEM(__pyx_t_9, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    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 = 2973; __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_12 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_12);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      #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 = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_14 = Py_TYPE(__pyx_t_11)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_14(__pyx_t_11); if (unlikely(!__pyx_t_1)) goto __pyx_L26_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_12 = __pyx_t_14(__pyx_t_11); if (unlikely(!__pyx_t_12)) goto __pyx_L26_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_12);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = NULL;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L27_unpacking_done;
      __pyx_L26_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_14 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L27_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_tup, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "plastid/genomics/roitools.pyx":2974
 *         # populate attr with real values from BED columns that are present
 *         for i, tup in sorted(bed_columns.items()):
 *             if num_bed_columns > i:             # <<<<<<<<<<<<<<
 *                 key     = tup[0]
 *                 default = tup[1]
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_num_bed_columns); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = PyObject_RichCompare(__pyx_t_2, __pyx_v_i, Py_GT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (__pyx_t_3) {

      /* "plastid/genomics/roitools.pyx":2975
 *         for i, tup in sorted(bed_columns.items()):
 *             if num_bed_columns > i:
 *                 key     = tup[0]             # <<<<<<<<<<<<<<
 *                 default = tup[1]
 *                 func    = tup[2]
 */
      __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_tup, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2975; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "plastid/genomics/roitools.pyx":2976
 *             if num_bed_columns > i:
 *                 key     = tup[0]
 *                 default = tup[1]             # <<<<<<<<<<<<<<
 *                 func    = tup[2]
 *                 try:
 */
      __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_tup, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2976; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_XDECREF_SET(__pyx_v_default, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "plastid/genomics/roitools.pyx":2977
 *                 key     = tup[0]
 *                 default = tup[1]
 *                 func    = tup[2]             # <<<<<<<<<<<<<<
 *                 try:
 *                     attr[key] = func(items[i])
 */
      __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_tup, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_XDECREF_SET(__pyx_v_func, __pyx_t_12);
      __pyx_t_12 = 0;

      /* "plastid/genomics/roitools.pyx":2978
 *                 default = tup[1]
 *                 func    = tup[2]
 *                 try:             # <<<<<<<<<<<<<<
 *                     attr[key] = func(items[i])
 *                 except ValueError:
 */
      {
        __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
        __Pyx_XGOTREF(__pyx_t_16);
        __Pyx_XGOTREF(__pyx_t_17);
        __Pyx_XGOTREF(__pyx_t_18);
        /*try:*/ {

          /* "plastid/genomics/roitools.pyx":2979
 *                 func    = tup[2]
 *                 try:
 *                     attr[key] = func(items[i])             # <<<<<<<<<<<<<<
 *                 except ValueError:
 *                     attr[key] = default
 */
          if (unlikely(__pyx_v_items == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2979; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
          }
          __pyx_t_2 = PyObject_GetItem(__pyx_v_items, __pyx_v_i); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2979; __pyx_clineno = __LINE__; goto __pyx_L29_error;};
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_v_func);
          __pyx_t_1 = __pyx_v_func; __pyx_t_11 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_11)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_11);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
            }
          }
          if (!__pyx_t_11) {
            __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2979; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_GOTREF(__pyx_t_12);
          } else {
            __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2979; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11); __pyx_t_11 = NULL;
            __Pyx_GIVEREF(__pyx_t_2);
            PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_2);
            __pyx_t_2 = 0;
            __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2979; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_v_key, __pyx_t_12) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2979; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "plastid/genomics/roitools.pyx":2978
 *                 default = tup[1]
 *                 func    = tup[2]
 *                 try:             # <<<<<<<<<<<<<<
 *                     attr[key] = func(items[i])
 *                 except ValueError:
 */
        }
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
        goto __pyx_L36_try_end;
        __pyx_L29_error:;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "plastid/genomics/roitools.pyx":2980
 *                 try:
 *                     attr[key] = func(items[i])
 *                 except ValueError:             # <<<<<<<<<<<<<<
 *                     attr[key] = default
 *             else:
 */
        __pyx_t_5 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
        if (__pyx_t_5) {
          __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.from_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_1, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2980; __pyx_clineno = __LINE__; goto __pyx_L31_except_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_6);

          /* "plastid/genomics/roitools.pyx":2981
 *                     attr[key] = func(items[i])
 *                 except ValueError:
 *                     attr[key] = default             # <<<<<<<<<<<<<<
 *             else:
 *                 break
 */
          if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_v_key, __pyx_v_default) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2981; __pyx_clineno = __LINE__; goto __pyx_L31_except_error;}
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L30_exception_handled;
        }
        goto __pyx_L31_except_error;
        __pyx_L31_except_error:;

        /* "plastid/genomics/roitools.pyx":2978
 *                 default = tup[1]
 *                 func    = tup[2]
 *                 try:             # <<<<<<<<<<<<<<
 *                     attr[key] = func(items[i])
 *                 except ValueError:
 */
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
        goto __pyx_L1_error;
        __pyx_L30_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_XGIVEREF(__pyx_t_17);
        __Pyx_XGIVEREF(__pyx_t_18);
        __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
        __pyx_L36_try_end:;
      }

      /* "plastid/genomics/roitools.pyx":2974
 *         # populate attr with real values from BED columns that are present
 *         for i, tup in sorted(bed_columns.items()):
 *             if num_bed_columns > i:             # <<<<<<<<<<<<<<
 *                 key     = tup[0]
 *                 default = tup[1]
 */
      goto __pyx_L28;
    }

    /* "plastid/genomics/roitools.pyx":2983
 *                     attr[key] = default
 *             else:
 *                 break             # <<<<<<<<<<<<<<
 * 
 *         # populate attr with values from remaining columns, if present
 */
    /*else*/ {
      goto __pyx_L25_break;
    }
    __pyx_L28:;

    /* "plastid/genomics/roitools.pyx":2973
 * 
 *         # populate attr with real values from BED columns that are present
 *         for i, tup in sorted(bed_columns.items()):             # <<<<<<<<<<<<<<
 *             if num_bed_columns > i:
 *                 key     = tup[0]
 */
  }
  __pyx_L25_break:;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "plastid/genomics/roitools.pyx":2986
 * 
 *         # populate attr with values from remaining columns, if present
 *         for i in range(num_bed_columns,len(items)):             # <<<<<<<<<<<<<<
 *             name, formatter = column_formatters[i-num_bed_columns]
 *             attr[name] = formatter(items[i])
 */
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_num_bed_columns); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = PyList_GET_SIZE(__pyx_v_items); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyTuple_New(2); 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_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
  __pyx_t_9 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_1 = __pyx_t_6; __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_6); 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_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_8(__pyx_t_1);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":2987
 *         # populate attr with values from remaining columns, if present
 *         for i in range(num_bed_columns,len(items)):
 *             name, formatter = column_formatters[i-num_bed_columns]             # <<<<<<<<<<<<<<
 *             attr[name] = formatter(items[i])
 * 
 */
    if (unlikely(!__pyx_v_column_formatters)) { __Pyx_RaiseUnboundLocalError("column_formatters"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_num_bed_columns); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyNumber_Subtract(__pyx_v_i, __pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_GetItem(__pyx_v_column_formatters, __pyx_t_9); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 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 = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_12);
      #else
      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_14 = Py_TYPE(__pyx_t_2)->tp_iternext;
      index = 0; __pyx_t_9 = __pyx_t_14(__pyx_t_2); if (unlikely(!__pyx_t_9)) goto __pyx_L41_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      index = 1; __pyx_t_12 = __pyx_t_14(__pyx_t_2); if (unlikely(!__pyx_t_12)) goto __pyx_L41_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_12);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = NULL;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L42_unpacking_done;
      __pyx_L41_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_14 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L42_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_9);
    __pyx_t_9 = 0;
    __Pyx_XDECREF_SET(__pyx_v_formatter, __pyx_t_12);
    __pyx_t_12 = 0;

    /* "plastid/genomics/roitools.pyx":2988
 *         for i in range(num_bed_columns,len(items)):
 *             name, formatter = column_formatters[i-num_bed_columns]
 *             attr[name] = formatter(items[i])             # <<<<<<<<<<<<<<
 * 
 *         # stash order of columns for export
 */
    if (unlikely(__pyx_v_items == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_12 = PyObject_GetItem(__pyx_v_items, __pyx_v_i); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_INCREF(__pyx_v_formatter);
    __pyx_t_9 = __pyx_v_formatter; __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_v_name, __pyx_t_6) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":2986
 * 
 *         # populate attr with values from remaining columns, if present
 *         for i in range(num_bed_columns,len(items)):             # <<<<<<<<<<<<<<
 *             name, formatter = column_formatters[i-num_bed_columns]
 *             attr[name] = formatter(items[i])
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2991
 * 
 *         # stash order of columns for export
 *         if num_bed_columns > 0:             # <<<<<<<<<<<<<<
 *             attr["_bedx_column_order"] = [X[0] for X in column_formatters]
 * 
 */
  __pyx_t_3 = ((__pyx_v_num_bed_columns > 0) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":2992
 *         # stash order of columns for export
 *         if num_bed_columns > 0:
 *             attr["_bedx_column_order"] = [X[0] for X in column_formatters]             # <<<<<<<<<<<<<<
 * 
 *         # convert color to hex string
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(!__pyx_v_column_formatters)) { __Pyx_RaiseUnboundLocalError("column_formatters"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (likely(PyList_CheckExact(__pyx_v_column_formatters)) || PyTuple_CheckExact(__pyx_v_column_formatters)) {
      __pyx_t_6 = __pyx_v_column_formatters; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_column_formatters); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_6))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_8(__pyx_t_6);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_X, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __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;
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_bedx_column_order, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":2991
 * 
 *         # stash order of columns for export
 *         if num_bed_columns > 0:             # <<<<<<<<<<<<<<
 *             attr["_bedx_column_order"] = [X[0] for X in column_formatters]
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":2995
 * 
 *         # convert color to hex string
 *         try:             # <<<<<<<<<<<<<<
 *             attr["color"] = get_str_from_rgb255(tuple([int(X) for X in attr["color"].split(",")]))
 *         except ValueError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
    __Pyx_XGOTREF(__pyx_t_18);
    __Pyx_XGOTREF(__pyx_t_17);
    __Pyx_XGOTREF(__pyx_t_16);
    /*try:*/ {

      /* "plastid/genomics/roitools.pyx":2996
 *         # convert color to hex string
 *         try:
 *             attr["color"] = get_str_from_rgb255(tuple([int(X) for X in attr["color"].split(",")]))             # <<<<<<<<<<<<<<
 *         except ValueError:
 *             attr["color"] = "#000000"
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_str_from_rgb255); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_color); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;};
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_split); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (likely(PyList_CheckExact(__pyx_t_11)) || PyTuple_CheckExact(__pyx_t_11)) {
        __pyx_t_12 = __pyx_t_11; __Pyx_INCREF(__pyx_t_12); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_8 = Py_TYPE(__pyx_t_12)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      for (;;) {
        if (likely(!__pyx_t_8)) {
          if (likely(PyList_CheckExact(__pyx_t_12))) {
            if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_12)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_11 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_7); __Pyx_INCREF(__pyx_t_11); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
            #else
            __pyx_t_11 = PySequence_ITEM(__pyx_t_12, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
            __Pyx_GOTREF(__pyx_t_11);
            #endif
          } else {
            if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_12)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_7); __Pyx_INCREF(__pyx_t_11); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
            #else
            __pyx_t_11 = PySequence_ITEM(__pyx_t_12, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
            __Pyx_GOTREF(__pyx_t_11);
            #endif
          }
        } else {
          __pyx_t_11 = __pyx_t_8(__pyx_t_12);
          if (unlikely(!__pyx_t_11)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_11 = PyNumber_Int(__pyx_v_X); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
        __Pyx_GOTREF(__pyx_t_11);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_9, (PyObject*)__pyx_t_11))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyList_AsTuple(((PyObject*)__pyx_t_9)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_12);
        __pyx_t_12 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_color, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L46_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "plastid/genomics/roitools.pyx":2995
 * 
 *         # convert color to hex string
 *         try:             # <<<<<<<<<<<<<<
 *             attr["color"] = get_str_from_rgb255(tuple([int(X) for X in attr["color"].split(",")]))
 *         except ValueError:
 */
    }
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    goto __pyx_L53_try_end;
    __pyx_L46_error:;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":2997
 *         try:
 *             attr["color"] = get_str_from_rgb255(tuple([int(X) for X in attr["color"].split(",")]))
 *         except ValueError:             # <<<<<<<<<<<<<<
 *             attr["color"] = "#000000"
 * 
 */
    __pyx_t_5 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
    if (__pyx_t_5) {
      __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.from_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2997; __pyx_clineno = __LINE__; goto __pyx_L48_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_11);

      /* "plastid/genomics/roitools.pyx":2998
 *             attr["color"] = get_str_from_rgb255(tuple([int(X) for X in attr["color"].split(",")]))
 *         except ValueError:
 *             attr["color"] = "#000000"             # <<<<<<<<<<<<<<
 * 
 *         # sanity check on thickstart and thickend
 */
      if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_color, __pyx_kp_s_000000) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2998; __pyx_clineno = __LINE__; goto __pyx_L48_except_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L47_exception_handled;
    }
    goto __pyx_L48_except_error;
    __pyx_L48_except_error:;

    /* "plastid/genomics/roitools.pyx":2995
 * 
 *         # convert color to hex string
 *         try:             # <<<<<<<<<<<<<<
 *             attr["color"] = get_str_from_rgb255(tuple([int(X) for X in attr["color"].split(",")]))
 *         except ValueError:
 */
    __Pyx_XGIVEREF(__pyx_t_18);
    __Pyx_XGIVEREF(__pyx_t_17);
    __Pyx_XGIVEREF(__pyx_t_16);
    __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_17, __pyx_t_16);
    goto __pyx_L1_error;
    __pyx_L47_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_18);
    __Pyx_XGIVEREF(__pyx_t_17);
    __Pyx_XGIVEREF(__pyx_t_16);
    __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_17, __pyx_t_16);
    __pyx_L53_try_end:;
  }

  /* "plastid/genomics/roitools.pyx":3001
 * 
 *         # sanity check on thickstart and thickend
 *         if attr["thickstart"] == attr["thickend"]: # if coding region is 0 length, RNA is non-coding             # <<<<<<<<<<<<<<
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif any([attr["thickstart"] is None, attr["thickend"] is None]):
 */
  __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_thickstart); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3001; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_thickend); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3001; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_11, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3002
 *         # sanity check on thickstart and thickend
 *         if attr["thickstart"] == attr["thickend"]: # if coding region is 0 length, RNA is non-coding
 *             attr["thickstart"] = attr["thickend"] = chrom_start             # <<<<<<<<<<<<<<
 *         elif any([attr["thickstart"] is None, attr["thickend"] is None]):
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 */
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_thickstart, __pyx_v_chrom_start) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_thickend, __pyx_v_chrom_start) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3001
 * 
 *         # sanity check on thickstart and thickend
 *         if attr["thickstart"] == attr["thickend"]: # if coding region is 0 length, RNA is non-coding             # <<<<<<<<<<<<<<
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif any([attr["thickstart"] is None, attr["thickend"] is None]):
 */
    goto __pyx_L58;
  }

  /* "plastid/genomics/roitools.pyx":3003
 *         if attr["thickstart"] == attr["thickend"]: # if coding region is 0 length, RNA is non-coding
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif any([attr["thickstart"] is None, attr["thickend"] is None]):             # <<<<<<<<<<<<<<
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif attr["thickstart"] < 0 or attr["thickend"] < 0:
 */
  __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_thickstart); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (__pyx_t_1 == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_thickend); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = (__pyx_t_6 == Py_None);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_11 = PyList_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_11, 1, __pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_any, __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3004
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif any([attr["thickstart"] is None, attr["thickend"] is None]):
 *             attr["thickstart"] = attr["thickend"] = chrom_start             # <<<<<<<<<<<<<<
 *         elif attr["thickstart"] < 0 or attr["thickend"] < 0:
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 */
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_thickstart, __pyx_v_chrom_start) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_thickend, __pyx_v_chrom_start) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3003
 *         if attr["thickstart"] == attr["thickend"]: # if coding region is 0 length, RNA is non-coding
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif any([attr["thickstart"] is None, attr["thickend"] is None]):             # <<<<<<<<<<<<<<
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif attr["thickstart"] < 0 or attr["thickend"] < 0:
 */
    goto __pyx_L58;
  }

  /* "plastid/genomics/roitools.pyx":3005
 *         elif any([attr["thickstart"] is None, attr["thickend"] is None]):
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif attr["thickstart"] < 0 or attr["thickend"] < 0:             # <<<<<<<<<<<<<<
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 * 
 */
  __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_thickstart); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_6 = PyObject_RichCompare(__pyx_t_11, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L59_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_thickend); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_11 = PyObject_RichCompare(__pyx_t_6, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_3 = __pyx_t_4;
  __pyx_L59_bool_binop_done:;
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3006
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif attr["thickstart"] < 0 or attr["thickend"] < 0:
 *             attr["thickstart"] = attr["thickend"] = chrom_start             # <<<<<<<<<<<<<<
 * 
 *         # convert blocks to GenomicSegments
 */
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_thickstart, __pyx_v_chrom_start) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_thickend, __pyx_v_chrom_start) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3005
 *         elif any([attr["thickstart"] is None, attr["thickend"] is None]):
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 *         elif attr["thickstart"] < 0 or attr["thickend"] < 0:             # <<<<<<<<<<<<<<
 *             attr["thickstart"] = attr["thickend"] = chrom_start
 * 
 */
  }
  __pyx_L58:;

  /* "plastid/genomics/roitools.pyx":3009
 * 
 *         # convert blocks to GenomicSegments
 *         num_frags    = int(attr["blocks"])             # <<<<<<<<<<<<<<
 *         frag_sizes   = [int(X) for X in attr["blocksizes"].strip(",").split(",")[:num_frags]]
 *         frag_offsets = [int(X) for X in attr["blockstarts"].strip(",").split(",")[:num_frags]]
 */
  __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_blocks); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_6 = PyNumber_Int(__pyx_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_num_frags = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "plastid/genomics/roitools.pyx":3010
 *         # convert blocks to GenomicSegments
 *         num_frags    = int(attr["blocks"])
 *         frag_sizes   = [int(X) for X in attr["blocksizes"].strip(",").split(",")[:num_frags]]             # <<<<<<<<<<<<<<
 *         frag_offsets = [int(X) for X in attr["blockstarts"].strip(",").split(",")[:num_frags]]
 *         for i in range(0,num_frags):
 */
  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_blocksizes); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_11, 0, 0, NULL, &__pyx_v_num_frags, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_11 = __pyx_t_1; __Pyx_INCREF(__pyx_t_11); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_11))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_11)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_11, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_11, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_8(__pyx_t_11);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Int(__pyx_v_X); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_frag_sizes = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "plastid/genomics/roitools.pyx":3011
 *         num_frags    = int(attr["blocks"])
 *         frag_sizes   = [int(X) for X in attr["blocksizes"].strip(",").split(",")[:num_frags]]
 *         frag_offsets = [int(X) for X in attr["blockstarts"].strip(",").split(",")[:num_frags]]             # <<<<<<<<<<<<<<
 *         for i in range(0,num_frags):
 *             frag_start = chrom_start + frag_offsets[i]
 */
  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_blockstarts); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_11, 0, 0, NULL, &__pyx_v_num_frags, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_11 = __pyx_t_1; __Pyx_INCREF(__pyx_t_11); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_11))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_11)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_11, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_11, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_8(__pyx_t_11);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Int(__pyx_v_X); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_frag_offsets = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "plastid/genomics/roitools.pyx":3012
 *         frag_sizes   = [int(X) for X in attr["blocksizes"].strip(",").split(",")[:num_frags]]
 *         frag_offsets = [int(X) for X in attr["blockstarts"].strip(",").split(",")[:num_frags]]
 *         for i in range(0,num_frags):             # <<<<<<<<<<<<<<
 *             frag_start = chrom_start + frag_offsets[i]
 *             frag_end   = frag_start  + frag_sizes[i]
 */
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0);
  __Pyx_INCREF(__pyx_v_num_frags);
  __Pyx_GIVEREF(__pyx_v_num_frags);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_num_frags);
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_11)) || PyTuple_CheckExact(__pyx_t_11)) {
    __pyx_t_6 = __pyx_t_11; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_11 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_11); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_11 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_11); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_11 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        #endif
      }
    } else {
      __pyx_t_11 = __pyx_t_8(__pyx_t_6);
      if (unlikely(!__pyx_t_11)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_11);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_11);
    __pyx_t_11 = 0;

    /* "plastid/genomics/roitools.pyx":3013
 *         frag_offsets = [int(X) for X in attr["blockstarts"].strip(",").split(",")[:num_frags]]
 *         for i in range(0,num_frags):
 *             frag_start = chrom_start + frag_offsets[i]             # <<<<<<<<<<<<<<
 *             frag_end   = frag_start  + frag_sizes[i]
 *             frags.append(GenomicSegment(chrom,frag_start,frag_end,strand))
 */
    __pyx_t_11 = PyObject_GetItem(__pyx_v_frag_offsets, __pyx_v_i); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3013; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = PyNumber_Add(__pyx_v_chrom_start, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_frag_start, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3014
 *         for i in range(0,num_frags):
 *             frag_start = chrom_start + frag_offsets[i]
 *             frag_end   = frag_start  + frag_sizes[i]             # <<<<<<<<<<<<<<
 *             frags.append(GenomicSegment(chrom,frag_start,frag_end,strand))
 * 
 */
    __pyx_t_1 = PyObject_GetItem(__pyx_v_frag_sizes, __pyx_v_i); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3014; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = PyNumber_Add(__pyx_v_frag_start, __pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_frag_end, __pyx_t_11);
    __pyx_t_11 = 0;

    /* "plastid/genomics/roitools.pyx":3015
 *             frag_start = chrom_start + frag_offsets[i]
 *             frag_end   = frag_start  + frag_sizes[i]
 *             frags.append(GenomicSegment(chrom,frag_start,frag_end,strand))             # <<<<<<<<<<<<<<
 * 
 *         # clean up attr
 */
    __pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_chrom);
    __Pyx_INCREF(__pyx_v_frag_start);
    __Pyx_GIVEREF(__pyx_v_frag_start);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_frag_start);
    __Pyx_INCREF(__pyx_v_frag_end);
    __Pyx_GIVEREF(__pyx_v_frag_end);
    PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_v_frag_end);
    __Pyx_INCREF(__pyx_v_strand);
    __Pyx_GIVEREF(__pyx_v_strand);
    PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_v_strand);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_15 = __Pyx_PyList_Append(__pyx_v_frags, __pyx_t_1); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3012
 *         frag_sizes   = [int(X) for X in attr["blocksizes"].strip(",").split(",")[:num_frags]]
 *         frag_offsets = [int(X) for X in attr["blockstarts"].strip(",").split(",")[:num_frags]]
 *         for i in range(0,num_frags):             # <<<<<<<<<<<<<<
 *             frag_start = chrom_start + frag_offsets[i]
 *             frag_end   = frag_start  + frag_sizes[i]
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "plastid/genomics/roitools.pyx":3018
 * 
 *         # clean up attr
 *         for k in ("blocks","blocksizes","blockstarts"):             # <<<<<<<<<<<<<<
 *             attr.pop(k)
 * 
 */
  __pyx_t_6 = __pyx_tuple__37; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
  for (;;) {
    if (__pyx_t_7 >= 3) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; 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);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3019
 *         # clean up attr
 *         for k in ("blocks","blocksizes","blockstarts"):
 *             attr.pop(k)             # <<<<<<<<<<<<<<
 * 
 *         return SegmentChain(*frags,**attr)
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_attr, __pyx_n_s_pop); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_k); 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);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_INCREF(__pyx_v_k);
      __Pyx_GIVEREF(__pyx_v_k);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_k);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); 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_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3018
 * 
 *         # clean up attr
 *         for k in ("blocks","blocksizes","blockstarts"):             # <<<<<<<<<<<<<<
 *             attr.pop(k)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "plastid/genomics/roitools.pyx":3021
 *             attr.pop(k)
 * 
 *         return SegmentChain(*frags,**attr)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = PySequence_Tuple(__pyx_v_frags); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_6, __pyx_v_attr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":2873
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line, extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `BED`_ file.
 *         The `BED`_ line may contain 4 to 12 columns, per the specification.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.from_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_frags);
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_column_formatters);
  __Pyx_XDECREF(__pyx_v_types);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_chrom_start);
  __Pyx_XDECREF(__pyx_v_chrom_end);
  __Pyx_XDECREF(__pyx_v_strand);
  __Pyx_XDECREF(__pyx_v_default_id);
  __Pyx_XDECREF(__pyx_v_bed_columns);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_tup);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_default);
  __Pyx_XDECREF(__pyx_v_func);
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XDECREF(__pyx_v_formatter);
  __Pyx_XDECREF(__pyx_v_num_frags);
  __Pyx_XDECREF(__pyx_v_frag_sizes);
  __Pyx_XDECREF(__pyx_v_frag_offsets);
  __Pyx_XDECREF(__pyx_v_frag_start);
  __Pyx_XDECREF(__pyx_v_frag_end);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3024
 * 
 *     @staticmethod
 *     def from_psl(psl_line):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `PSL`_ (BLAT) file
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_99from_psl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_98from_psl[] = "SegmentChain.from_psl(psl_line)\nCreate a |SegmentChain| from a line from a `PSL`_ (BLAT) file\n\n        See the `PSL spec <http://pombe.nci.nih.gov/genome/goldenPath/help/blatSpec.html>`_\n        \n        Parameters\n        ----------\n        psl_line : str\n            Line from a `PSL`_ file\n\n        Returns\n        -------\n        |SegmentChain|\n        ";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_12SegmentChain_99from_psl = {"from_psl", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_99from_psl, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_98from_psl};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_99from_psl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_psl_line = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_psl (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_psl_line,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_psl_line)) != 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, "from_psl") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __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_psl_line = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_psl", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.from_psl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_98from_psl(__pyx_v_psl_line);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_98from_psl(PyObject *__pyx_v_psl_line) {
  PyObject *__pyx_v_items = 0;
  PyObject *__pyx_v_segs = 0;
  PyObject *__pyx_v_q_starts = 0;
  PyObject *__pyx_v_t_starts = 0;
  PyObject *__pyx_v_attr = 0;
  long __pyx_v_t_start;
  long __pyx_v_block_size;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_seg = 0;
  PyObject *__pyx_v_block_sizes = 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 *);
  long __pyx_t_9;
  long __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("from_psl", 0);

  /* "plastid/genomics/roitools.pyx":3039
 *         """
 *         cdef:
 *             list items = psl_line.strip().split("\t")             # <<<<<<<<<<<<<<
 *             list segs = []
 *             list block_starts, q_starts, t_starts
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_psl_line, __pyx_n_s_strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3039; __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_PyObject_Call(__pyx_t_2, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_items = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3040
 *         cdef:
 *             list items = psl_line.strip().split("\t")
 *             list segs = []             # <<<<<<<<<<<<<<
 *             list block_starts, q_starts, t_starts
 *             dict attr = {}
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_segs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3042
 *             list segs = []
 *             list block_starts, q_starts, t_starts
 *             dict attr = {}             # <<<<<<<<<<<<<<
 *             long t_start, block_size
 *             GenomicSegment seg
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3046
 *             GenomicSegment seg
 * 
 *         attr["type"]             = "alignment"             # <<<<<<<<<<<<<<
 *         attr["query_name"]       = items[9]
 *         attr["match_length"]     = int(items[0])
 */
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_type, __pyx_n_s_alignment) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3047
 * 
 *         attr["type"]             = "alignment"
 *         attr["query_name"]       = items[9]             # <<<<<<<<<<<<<<
 *         attr["match_length"]     = int(items[0])
 *         attr["mismatches"]       = int(items[1])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 9, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3047; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_query_name, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3048
 *         attr["type"]             = "alignment"
 *         attr["query_name"]       = items[9]
 *         attr["match_length"]     = int(items[0])             # <<<<<<<<<<<<<<
 *         attr["mismatches"]       = int(items[1])
 *         attr["rep_matches"]      = int(items[2])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_match_length, __pyx_t_2) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3049
 *         attr["query_name"]       = items[9]
 *         attr["match_length"]     = int(items[0])
 *         attr["mismatches"]       = int(items[1])             # <<<<<<<<<<<<<<
 *         attr["rep_matches"]      = int(items[2])
 *         attr["N"]                = int(items[3])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 1, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3049; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_mismatches, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3050
 *         attr["match_length"]     = int(items[0])
 *         attr["mismatches"]       = int(items[1])
 *         attr["rep_matches"]      = int(items[2])             # <<<<<<<<<<<<<<
 *         attr["N"]                = int(items[3])
 *         attr["query_gap_count"]  = int(items[4])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 2, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_rep_matches, __pyx_t_2) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3051
 *         attr["mismatches"]       = int(items[1])
 *         attr["rep_matches"]      = int(items[2])
 *         attr["N"]                = int(items[3])             # <<<<<<<<<<<<<<
 *         attr["query_gap_count"]  = int(items[4])
 *         attr["query_gap_bases"]  = int(items[5])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 3, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3051; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_N, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3052
 *         attr["rep_matches"]      = int(items[2])
 *         attr["N"]                = int(items[3])
 *         attr["query_gap_count"]  = int(items[4])             # <<<<<<<<<<<<<<
 *         attr["query_gap_bases"]  = int(items[5])
 *         attr["target_gap_count"] = int(items[6])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 4, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_query_gap_count, __pyx_t_2) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3053
 *         attr["N"]                = int(items[3])
 *         attr["query_gap_count"]  = int(items[4])
 *         attr["query_gap_bases"]  = int(items[5])             # <<<<<<<<<<<<<<
 *         attr["target_gap_count"] = int(items[6])
 *         attr["target_gap_bases"] = int(items[7])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 5, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_query_gap_bases, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3054
 *         attr["query_gap_count"]  = int(items[4])
 *         attr["query_gap_bases"]  = int(items[5])
 *         attr["target_gap_count"] = int(items[6])             # <<<<<<<<<<<<<<
 *         attr["target_gap_bases"] = int(items[7])
 *         attr["strand"]           = items[8]
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 6, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_target_gap_count, __pyx_t_2) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3055
 *         attr["query_gap_bases"]  = int(items[5])
 *         attr["target_gap_count"] = int(items[6])
 *         attr["target_gap_bases"] = int(items[7])             # <<<<<<<<<<<<<<
 *         attr["strand"]           = items[8]
 *         attr["query_length"]     = int(items[10])
 */
  if (unlikely(__pyx_v_items == 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;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 7, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_target_gap_bases, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3056
 *         attr["target_gap_count"] = int(items[6])
 *         attr["target_gap_bases"] = int(items[7])
 *         attr["strand"]           = items[8]             # <<<<<<<<<<<<<<
 *         attr["query_length"]     = int(items[10])
 *         attr["query_start"]      = int(items[11])
 */
  if (unlikely(__pyx_v_items == 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_1 = __Pyx_GetItemInt_List(__pyx_v_items, 8, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_strand, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3057
 *         attr["target_gap_bases"] = int(items[7])
 *         attr["strand"]           = items[8]
 *         attr["query_length"]     = int(items[10])             # <<<<<<<<<<<<<<
 *         attr["query_start"]      = int(items[11])
 *         attr["query_end"]        = int(items[12])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 10, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3057; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_query_length, __pyx_t_2) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3058
 *         attr["strand"]           = items[8]
 *         attr["query_length"]     = int(items[10])
 *         attr["query_start"]      = int(items[11])             # <<<<<<<<<<<<<<
 *         attr["query_end"]        = int(items[12])
 *         attr["target_name"]      = items[13]
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 11, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_query_start, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3059
 *         attr["query_length"]     = int(items[10])
 *         attr["query_start"]      = int(items[11])
 *         attr["query_end"]        = int(items[12])             # <<<<<<<<<<<<<<
 *         attr["target_name"]      = items[13]
 *         attr["target_length"]    = int(items[14])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_items, 12, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_query_end, __pyx_t_2) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3060
 *         attr["query_start"]      = int(items[11])
 *         attr["query_end"]        = int(items[12])
 *         attr["target_name"]      = items[13]             # <<<<<<<<<<<<<<
 *         attr["target_length"]    = int(items[14])
 *         attr["target_start"]     = int(items[15])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 13, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3060; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_target_name, __pyx_t_2) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3061
 *         attr["query_end"]        = int(items[12])
 *         attr["target_name"]      = items[13]
 *         attr["target_length"]    = int(items[14])             # <<<<<<<<<<<<<<
 *         attr["target_start"]     = int(items[15])
 *         attr["target_end"]       = int(items[16])
 */
  if (unlikely(__pyx_v_items == 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_GetItemInt_List(__pyx_v_items, 14, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_target_length, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3062
 *         attr["target_name"]      = items[13]
 *         attr["target_length"]    = int(items[14])
 *         attr["target_start"]     = int(items[15])             # <<<<<<<<<<<<<<
 *         attr["target_end"]       = int(items[16])
 *         attr["ID"]               = attr["query_name"]
 */
  if (unlikely(__pyx_v_items == 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_1 = __Pyx_GetItemInt_List(__pyx_v_items, 15, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3062; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_target_start, __pyx_t_2) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3063
 *         attr["target_length"]    = int(items[14])
 *         attr["target_start"]     = int(items[15])
 *         attr["target_end"]       = int(items[16])             # <<<<<<<<<<<<<<
 *         attr["ID"]               = attr["query_name"]
 *         #block_count           = int(items[17])
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 16, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3063; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_target_end, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3064
 *         attr["target_start"]     = int(items[15])
 *         attr["target_end"]       = int(items[16])
 *         attr["ID"]               = attr["query_name"]             # <<<<<<<<<<<<<<
 *         #block_count           = int(items[17])
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_query_name); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3064; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_ID, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3067
 *         #block_count           = int(items[17])
 * 
 *         block_sizes = [int(X) for X in items[18].strip(",").split(",")]             # <<<<<<<<<<<<<<
 *         q_starts    = [int(X) for X in items[19].strip(",").split(",")]
 *         t_starts    = [int(X) for X in items[20].strip(",").split(",")]
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_items, 18, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(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 = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(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 = 3067; __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 = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        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 = 3067; __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 = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Int(__pyx_v_X); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __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_v_block_sizes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3068
 * 
 *         block_sizes = [int(X) for X in items[18].strip(",").split(",")]
 *         q_starts    = [int(X) for X in items[19].strip(",").split(",")]             # <<<<<<<<<<<<<<
 *         t_starts    = [int(X) for X in items[20].strip(",").split(",")]
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_items, 19, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(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 = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(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 = 3068; __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 = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        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 = 3068; __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 = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Int(__pyx_v_X); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_q_starts = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3069
 *         block_sizes = [int(X) for X in items[18].strip(",").split(",")]
 *         q_starts    = [int(X) for X in items[19].strip(",").split(",")]
 *         t_starts    = [int(X) for X in items[20].strip(",").split(",")]             # <<<<<<<<<<<<<<
 * 
 *         attr["q_starts"] = q_starts
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_items == 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_2 = __Pyx_GetItemInt_List(__pyx_v_items, 20, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_strip); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(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 = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(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 = 3069; __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 = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        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 = 3069; __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 = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Int(__pyx_v_X); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __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_v_t_starts = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3071
 *         t_starts    = [int(X) for X in items[20].strip(",").split(",")]
 * 
 *         attr["q_starts"] = q_starts             # <<<<<<<<<<<<<<
 *         attr["t_starts"] = t_starts
 * 
 */
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_q_starts, __pyx_v_q_starts) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3072
 * 
 *         attr["q_starts"] = q_starts
 *         attr["t_starts"] = t_starts             # <<<<<<<<<<<<<<
 * 
 *         for t_start, block_size in zip(t_starts,block_sizes):
 */
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_t_starts, __pyx_v_t_starts) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3074
 *         attr["t_starts"] = t_starts
 * 
 *         for t_start, block_size in zip(t_starts,block_sizes):             # <<<<<<<<<<<<<<
 *             seg = GenomicSegment(attr["target_name"],
 *                                  t_start,
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_t_starts);
  __Pyx_GIVEREF(__pyx_v_t_starts);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_t_starts);
  __Pyx_INCREF(__pyx_v_block_sizes);
  __Pyx_GIVEREF(__pyx_v_block_sizes);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_block_sizes);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(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 = 3074; __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 = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        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 = 3074; __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 = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __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 = 3074; __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 = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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_L11_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_L11_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 = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L12_unpacking_done;
      __pyx_L11_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 = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L12_unpacking_done:;
    }
    __pyx_t_9 = __Pyx_PyInt_As_long(__pyx_t_2); if (unlikely((__pyx_t_9 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_10 = __Pyx_PyInt_As_long(__pyx_t_6); if (unlikely((__pyx_t_10 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_t_start = __pyx_t_9;
    __pyx_v_block_size = __pyx_t_10;

    /* "plastid/genomics/roitools.pyx":3075
 * 
 *         for t_start, block_size in zip(t_starts,block_sizes):
 *             seg = GenomicSegment(attr["target_name"],             # <<<<<<<<<<<<<<
 *                                  t_start,
 *                                  t_start + block_size,
 */
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_target_name); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3075; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);

    /* "plastid/genomics/roitools.pyx":3076
 *         for t_start, block_size in zip(t_starts,block_sizes):
 *             seg = GenomicSegment(attr["target_name"],
 *                                  t_start,             # <<<<<<<<<<<<<<
 *                                  t_start + block_size,
 *                                  attr["strand"])
 */
    __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_t_start); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "plastid/genomics/roitools.pyx":3077
 *             seg = GenomicSegment(attr["target_name"],
 *                                  t_start,
 *                                  t_start + block_size,             # <<<<<<<<<<<<<<
 *                                  attr["strand"])
 *             segs.append(seg)
 */
    __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_t_start + __pyx_v_block_size)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);

    /* "plastid/genomics/roitools.pyx":3078
 *                                  t_start,
 *                                  t_start + block_size,
 *                                  attr["strand"])             # <<<<<<<<<<<<<<
 *             segs.append(seg)
 * 
 */
    __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_attr, __pyx_n_s_strand); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3078; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_7);

    /* "plastid/genomics/roitools.pyx":3075
 * 
 *         for t_start, block_size in zip(t_starts,block_sizes):
 *             seg = GenomicSegment(attr["target_name"],             # <<<<<<<<<<<<<<
 *                                  t_start,
 *                                  t_start + block_size,
 */
    __pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_7);
    __pyx_t_3 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_seg, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "plastid/genomics/roitools.pyx":3079
 *                                  t_start + block_size,
 *                                  attr["strand"])
 *             segs.append(seg)             # <<<<<<<<<<<<<<
 * 
 *         return SegmentChain(*segs,**attr)
 */
    __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_segs, ((PyObject *)__pyx_v_seg)); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3074
 *         attr["t_starts"] = t_starts
 * 
 *         for t_start, block_size in zip(t_starts,block_sizes):             # <<<<<<<<<<<<<<
 *             seg = GenomicSegment(attr["target_name"],
 *                                  t_start,
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3081
 *             segs.append(seg)
 * 
 *         return SegmentChain(*segs,**attr)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PySequence_Tuple(__pyx_v_segs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3024
 * 
 *     @staticmethod
 *     def from_psl(psl_line):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `PSL`_ (BLAT) file
 * 
 */

  /* function exit code */
  __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_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.from_psl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_items);
  __Pyx_XDECREF(__pyx_v_segs);
  __Pyx_XDECREF(__pyx_v_q_starts);
  __Pyx_XDECREF(__pyx_v_t_starts);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF((PyObject *)__pyx_v_seg);
  __Pyx_XDECREF(__pyx_v_block_sizes);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pxd":29
 *     cdef:
 *         list _segments, _mask_segments
 *         readonly GenomicSegment spanning_segment             # <<<<<<<<<<<<<<
 *         readonly long length
 *         readonly long masked_length
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_16spanning_segment_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_16spanning_segment_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_16spanning_segment___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_16spanning_segment___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->spanning_segment));
  __pyx_r = ((PyObject *)__pyx_v_self->spanning_segment);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pxd":30
 *         list _segments, _mask_segments
 *         readonly GenomicSegment spanning_segment
 *         readonly long length             # <<<<<<<<<<<<<<
 *         readonly long masked_length
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_6length_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_6length_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6length___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_6length___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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 = __Pyx_PyInt_From_long(__pyx_v_self->length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.length.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pxd":31
 *         readonly GenomicSegment spanning_segment
 *         readonly long length
 *         readonly long masked_length             # <<<<<<<<<<<<<<
 * 
 *         array.array _position_hash
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13masked_length_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13masked_length_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_13masked_length___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_13masked_length___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__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 = __Pyx_PyInt_From_long(__pyx_v_self->masked_length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.masked_length.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pxd":35
 *         array.array _position_hash
 *         array.array _position_mask # really should be bint, but we can't use it there
 *         public dict attr             # <<<<<<<<<<<<<<
 *         dict _inverse_hash
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr___get__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->attr);
  __pyx_r = __pyx_v_self->attr;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr_2__set__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self, PyObject *__pyx_v_value) {
  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("__set__", 0);
  if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->attr);
  __Pyx_DECREF(__pyx_v_self->attr);
  __pyx_v_self->attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.SegmentChain.attr.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr_4__del__(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_12SegmentChain_4attr_4__del__(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->attr);
  __Pyx_DECREF(__pyx_v_self->attr);
  __pyx_v_self->attr = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3125
 *     """
 * 
 *     def __cinit__(self,*segments,type=None,**attr):             # <<<<<<<<<<<<<<
 *         """Create a |Transcript|
 * 
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_type = 0;
  CYTHON_UNUSED PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_attr = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  __pyx_v_attr = PyDict_New(); if (unlikely(!__pyx_v_attr)) return -1;
  __Pyx_GOTREF(__pyx_v_attr);
  if (PyTuple_GET_SIZE(__pyx_args) > 0) {
    __pyx_v_segments = PyTuple_GetSlice(__pyx_args, 0, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_segments)) {
      __Pyx_DECREF(__pyx_v_attr); __pyx_v_attr = 0;
      __Pyx_RefNannyFinishContext();
      return -1;
    }
    __Pyx_GOTREF(__pyx_v_segments);
  } else {
    __pyx_v_segments = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_type,0};
    PyObject* values[1] = {0};
    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) {
        default:
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      if (kw_args == 1) {
        const Py_ssize_t index = 0;
        PyObject* value = PyDict_GetItem(__pyx_kwds, *__pyx_pyargnames[index]);
        if (value) { values[index] = value; kw_args--; }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_attr, values, 0, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 0) {
      goto __pyx_L5_argtuple_error;
    } else {
    }
    __pyx_v_type = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 0, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_segments); __pyx_v_segments = 0;
  __Pyx_DECREF(__pyx_v_attr); __pyx_v_attr = 0;
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript___cinit__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), __pyx_v_type, __pyx_v_segments, __pyx_v_attr);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_segments);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript___cinit__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_type, CYTHON_UNUSED PyObject *__pyx_v_segments, PyObject *__pyx_v_attr) {
  PyObject *__pyx_v_gstart = NULL;
  PyObject *__pyx_v_gend = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("__cinit__", 0);

  /* "plastid/genomics/roitools.pyx":3158
 *             Otherwise, generated from genomic coordinates.
 *         """
 *         if type == None:             # <<<<<<<<<<<<<<
 *             self.attr["type"] = "mRNA"
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_type, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3158; __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 = 3158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3159
 *         """
 *         if type == None:
 *             self.attr["type"] = "mRNA"             # <<<<<<<<<<<<<<
 * 
 *         gstart = attr.get("cds_genome_start",None)
 */
    if (unlikely(__pyx_v_self->__pyx_base.attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (unlikely(PyDict_SetItem(__pyx_v_self->__pyx_base.attr, __pyx_n_s_type, __pyx_n_s_mRNA) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3158
 *             Otherwise, generated from genomic coordinates.
 *         """
 *         if type == None:             # <<<<<<<<<<<<<<
 *             self.attr["type"] = "mRNA"
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":3161
 *             self.attr["type"] = "mRNA"
 * 
 *         gstart = attr.get("cds_genome_start",None)             # <<<<<<<<<<<<<<
 *         gend   = attr.get("cds_genome_end"  ,None)
 *         self.cds_genome_start = gstart
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_attr, __pyx_n_s_cds_genome_start, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_gstart = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3162
 * 
 *         gstart = attr.get("cds_genome_start",None)
 *         gend   = attr.get("cds_genome_end"  ,None)             # <<<<<<<<<<<<<<
 *         self.cds_genome_start = gstart
 *         self.cds_genome_end   = gend
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_attr, __pyx_n_s_cds_genome_end, Py_None); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_gend = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3163
 *         gstart = attr.get("cds_genome_start",None)
 *         gend   = attr.get("cds_genome_end"  ,None)
 *         self.cds_genome_start = gstart             # <<<<<<<<<<<<<<
 *         self.cds_genome_end   = gend
 * 
 */
  __Pyx_INCREF(__pyx_v_gstart);
  __Pyx_GIVEREF(__pyx_v_gstart);
  __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
  __Pyx_DECREF(__pyx_v_self->cds_genome_start);
  __pyx_v_self->cds_genome_start = __pyx_v_gstart;

  /* "plastid/genomics/roitools.pyx":3164
 *         gend   = attr.get("cds_genome_end"  ,None)
 *         self.cds_genome_start = gstart
 *         self.cds_genome_end   = gend             # <<<<<<<<<<<<<<
 * 
 *         if gstart is not None and gend is not None:
 */
  __Pyx_INCREF(__pyx_v_gend);
  __Pyx_GIVEREF(__pyx_v_gend);
  __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
  __Pyx_DECREF(__pyx_v_self->cds_genome_end);
  __pyx_v_self->cds_genome_end = __pyx_v_gend;

  /* "plastid/genomics/roitools.pyx":3166
 *         self.cds_genome_end   = gend
 * 
 *         if gstart is not None and gend is not None:             # <<<<<<<<<<<<<<
 *             self._update_cds()
 *         else:
 */
  __pyx_t_3 = (__pyx_v_gstart != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_gend != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3167
 * 
 *         if gstart is not None and gend is not None:
 *             self._update_cds()             # <<<<<<<<<<<<<<
 *         else:
 *             self.cds_genome_start = None
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->_update_cds(__pyx_v_self); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3166
 *         self.cds_genome_end   = gend
 * 
 *         if gstart is not None and gend is not None:             # <<<<<<<<<<<<<<
 *             self._update_cds()
 *         else:
 */
    goto __pyx_L4;
  }

  /* "plastid/genomics/roitools.pyx":3169
 *             self._update_cds()
 *         else:
 *             self.cds_genome_start = None             # <<<<<<<<<<<<<<
 *             self.cds_genome_end = None
 *             self.cds_start = None
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
    __Pyx_DECREF(__pyx_v_self->cds_genome_start);
    __pyx_v_self->cds_genome_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3170
 *         else:
 *             self.cds_genome_start = None
 *             self.cds_genome_end = None             # <<<<<<<<<<<<<<
 *             self.cds_start = None
 *             self.cds_end = None
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
    __Pyx_DECREF(__pyx_v_self->cds_genome_end);
    __pyx_v_self->cds_genome_end = Py_None;

    /* "plastid/genomics/roitools.pyx":3171
 *             self.cds_genome_start = None
 *             self.cds_genome_end = None
 *             self.cds_start = None             # <<<<<<<<<<<<<<
 *             self.cds_end = None
 * 
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3172
 *             self.cds_genome_end = None
 *             self.cds_start = None
 *             self.cds_end = None             # <<<<<<<<<<<<<<
 * 
 *     def __copy__(self):  # copy info and segments; shallow copy attr
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_end);
    __Pyx_DECREF(__pyx_v_self->cds_end);
    __pyx_v_self->cds_end = Py_None;
  }
  __pyx_L4:;

  /* "plastid/genomics/roitools.pyx":3125
 *     """
 * 
 *     def __cinit__(self,*segments,type=None,**attr):             # <<<<<<<<<<<<<<
 *         """Create a |Transcript|
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gstart);
  __Pyx_XDECREF(__pyx_v_gend);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3174
 *             self.cds_end = None
 * 
 *     def __copy__(self):  # copy info and segments; shallow copy attr             # <<<<<<<<<<<<<<
 *         chain2 = Transcript()
 *         chain2._set_segments(self._segments)
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_3__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_2__copy__[] = "Transcript.__copy__(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_3__copy__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__copy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_2__copy__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_2__copy__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_chain2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__copy__", 0);

  /* "plastid/genomics/roitools.pyx":3175
 * 
 *     def __copy__(self):  # copy info and segments; shallow copy attr
 *         chain2 = Transcript()             # <<<<<<<<<<<<<<
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(self._mask_segments)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_chain2 = ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3176
 *     def __copy__(self):  # copy info and segments; shallow copy attr
 *         chain2 = Transcript()
 *         chain2._set_segments(self._segments)             # <<<<<<<<<<<<<<
 *         chain2._set_masks(self._mask_segments)
 *         chain2.cds_genome_start = self.cds_genome_start
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base._segments;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_chain2->__pyx_base.__pyx_vtab)->__pyx_base._set_segments(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3177
 *         chain2 = Transcript()
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(self._mask_segments)             # <<<<<<<<<<<<<<
 *         chain2.cds_genome_start = self.cds_genome_start
 *         chain2.cds_genome_end = self.cds_genome_end
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base._mask_segments;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_chain2->__pyx_base.__pyx_vtab)->__pyx_base._set_masks(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3178
 *         chain2._set_segments(self._segments)
 *         chain2._set_masks(self._mask_segments)
 *         chain2.cds_genome_start = self.cds_genome_start             # <<<<<<<<<<<<<<
 *         chain2.cds_genome_end = self.cds_genome_end
 *         if chain2.cds_genome_start is not None:
 */
  __pyx_t_1 = __pyx_v_self->cds_genome_start;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chain2->cds_genome_start);
  __Pyx_DECREF(__pyx_v_chain2->cds_genome_start);
  __pyx_v_chain2->cds_genome_start = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3179
 *         chain2._set_masks(self._mask_segments)
 *         chain2.cds_genome_start = self.cds_genome_start
 *         chain2.cds_genome_end = self.cds_genome_end             # <<<<<<<<<<<<<<
 *         if chain2.cds_genome_start is not None:
 *             chain2._update_from_cds_genome_start()
 */
  __pyx_t_1 = __pyx_v_self->cds_genome_end;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chain2->cds_genome_end);
  __Pyx_DECREF(__pyx_v_chain2->cds_genome_end);
  __pyx_v_chain2->cds_genome_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3180
 *         chain2.cds_genome_start = self.cds_genome_start
 *         chain2.cds_genome_end = self.cds_genome_end
 *         if chain2.cds_genome_start is not None:             # <<<<<<<<<<<<<<
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:
 */
  __pyx_t_2 = (__pyx_v_chain2->cds_genome_start != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3181
 *         chain2.cds_genome_end = self.cds_genome_end
 *         if chain2.cds_genome_start is not None:
 *             chain2._update_from_cds_genome_start()             # <<<<<<<<<<<<<<
 *         if chain2.cds_genome_end is not None:
 *             chain2._update_from_cds_genome_end()
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_chain2->__pyx_base.__pyx_vtab)->_update_from_cds_genome_start(__pyx_v_chain2); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3180
 *         chain2.cds_genome_start = self.cds_genome_start
 *         chain2.cds_genome_end = self.cds_genome_end
 *         if chain2.cds_genome_start is not None:             # <<<<<<<<<<<<<<
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:
 */
  }

  /* "plastid/genomics/roitools.pyx":3182
 *         if chain2.cds_genome_start is not None:
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 *             chain2._update_from_cds_genome_end()
 *         chain2.attr = self.attr
 */
  __pyx_t_3 = (__pyx_v_chain2->cds_genome_end != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3183
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:
 *             chain2._update_from_cds_genome_end()             # <<<<<<<<<<<<<<
 *         chain2.attr = self.attr
 *         return chain2
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_chain2->__pyx_base.__pyx_vtab)->_update_from_cds_genome_end(__pyx_v_chain2); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3182
 *         if chain2.cds_genome_start is not None:
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 *             chain2._update_from_cds_genome_end()
 *         chain2.attr = self.attr
 */
  }

  /* "plastid/genomics/roitools.pyx":3184
 *         if chain2.cds_genome_end is not None:
 *             chain2._update_from_cds_genome_end()
 *         chain2.attr = self.attr             # <<<<<<<<<<<<<<
 *         return chain2
 * 
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.attr;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chain2->__pyx_base.attr);
  __Pyx_DECREF(__pyx_v_chain2->__pyx_base.attr);
  __pyx_v_chain2->__pyx_base.attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3185
 *             chain2._update_from_cds_genome_end()
 *         chain2.attr = self.attr
 *         return chain2             # <<<<<<<<<<<<<<
 * 
 *     def __deepcopy__(self,memo): # deep copy everything
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_chain2));
  __pyx_r = ((PyObject *)__pyx_v_chain2);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3174
 *             self.cds_end = None
 * 
 *     def __copy__(self):  # copy info and segments; shallow copy attr             # <<<<<<<<<<<<<<
 *         chain2 = Transcript()
 *         chain2._set_segments(self._segments)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.__copy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_chain2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3187
 *         return chain2
 * 
 *     def __deepcopy__(self,memo): # deep copy everything             # <<<<<<<<<<<<<<
 *         chain2 = Transcript()
 *         chain2._set_segments(copy.deepcopy(self._segments))
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_5__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_4__deepcopy__[] = "Transcript.__deepcopy__(self, memo)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_5__deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_v_memo) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__deepcopy__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_4__deepcopy__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), ((PyObject *)__pyx_v_memo));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_4__deepcopy__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_memo) {
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_chain2 = 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;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__deepcopy__", 0);

  /* "plastid/genomics/roitools.pyx":3188
 * 
 *     def __deepcopy__(self,memo): # deep copy everything
 *         chain2 = Transcript()             # <<<<<<<<<<<<<<
 *         chain2._set_segments(copy.deepcopy(self._segments))
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_chain2 = ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3189
 *     def __deepcopy__(self,memo): # deep copy everything
 *         chain2 = Transcript()
 *         chain2._set_segments(copy.deepcopy(self._segments))             # <<<<<<<<<<<<<<
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))
 *         chain2.cds_genome_start = self.cds_genome_start
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->__pyx_base._segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->__pyx_base._segments);
    __Pyx_GIVEREF(__pyx_v_self->__pyx_base._segments);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->__pyx_base._segments);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_chain2->__pyx_base.__pyx_vtab)->__pyx_base._set_segments(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3190
 *         chain2 = Transcript()
 *         chain2._set_segments(copy.deepcopy(self._segments))
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))             # <<<<<<<<<<<<<<
 *         chain2.cds_genome_start = self.cds_genome_start
 *         chain2.cds_genome_end = self.cds_genome_end
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->__pyx_base._mask_segments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_self->__pyx_base._mask_segments);
    __Pyx_GIVEREF(__pyx_v_self->__pyx_base._mask_segments);
    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_self->__pyx_base._mask_segments);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_chain2->__pyx_base.__pyx_vtab)->__pyx_base._set_masks(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_chain2), ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3191
 *         chain2._set_segments(copy.deepcopy(self._segments))
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))
 *         chain2.cds_genome_start = self.cds_genome_start             # <<<<<<<<<<<<<<
 *         chain2.cds_genome_end = self.cds_genome_end
 *         if chain2.cds_genome_start is not None:
 */
  __pyx_t_1 = __pyx_v_self->cds_genome_start;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chain2->cds_genome_start);
  __Pyx_DECREF(__pyx_v_chain2->cds_genome_start);
  __pyx_v_chain2->cds_genome_start = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3192
 *         chain2._set_masks(copy.deepcopy(self._mask_segments))
 *         chain2.cds_genome_start = self.cds_genome_start
 *         chain2.cds_genome_end = self.cds_genome_end             # <<<<<<<<<<<<<<
 *         if chain2.cds_genome_start is not None:
 *             chain2._update_from_cds_genome_start()
 */
  __pyx_t_1 = __pyx_v_self->cds_genome_end;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chain2->cds_genome_end);
  __Pyx_DECREF(__pyx_v_chain2->cds_genome_end);
  __pyx_v_chain2->cds_genome_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3193
 *         chain2.cds_genome_start = self.cds_genome_start
 *         chain2.cds_genome_end = self.cds_genome_end
 *         if chain2.cds_genome_start is not None:             # <<<<<<<<<<<<<<
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:
 */
  __pyx_t_5 = (__pyx_v_chain2->cds_genome_start != Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "plastid/genomics/roitools.pyx":3194
 *         chain2.cds_genome_end = self.cds_genome_end
 *         if chain2.cds_genome_start is not None:
 *             chain2._update_from_cds_genome_start()             # <<<<<<<<<<<<<<
 *         if chain2.cds_genome_end is not None:
 *             chain2._update_from_cds_genome_end()
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_chain2->__pyx_base.__pyx_vtab)->_update_from_cds_genome_start(__pyx_v_chain2); if (unlikely(__pyx_t_6 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3193
 *         chain2.cds_genome_start = self.cds_genome_start
 *         chain2.cds_genome_end = self.cds_genome_end
 *         if chain2.cds_genome_start is not None:             # <<<<<<<<<<<<<<
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:
 */
  }

  /* "plastid/genomics/roitools.pyx":3195
 *         if chain2.cds_genome_start is not None:
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 *             chain2._update_from_cds_genome_end()
 * 
 */
  __pyx_t_6 = (__pyx_v_chain2->cds_genome_end != Py_None);
  __pyx_t_5 = (__pyx_t_6 != 0);
  if (__pyx_t_5) {

    /* "plastid/genomics/roitools.pyx":3196
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:
 *             chain2._update_from_cds_genome_end()             # <<<<<<<<<<<<<<
 * 
 *         chain2.attr = copy.deepcopy(self.attr)
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_chain2->__pyx_base.__pyx_vtab)->_update_from_cds_genome_end(__pyx_v_chain2); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3195
 *         if chain2.cds_genome_start is not None:
 *             chain2._update_from_cds_genome_start()
 *         if chain2.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 *             chain2._update_from_cds_genome_end()
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":3198
 *             chain2._update_from_cds_genome_end()
 * 
 *         chain2.attr = copy.deepcopy(self.attr)             # <<<<<<<<<<<<<<
 *         return chain2
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->__pyx_base.attr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_self->__pyx_base.attr);
    __Pyx_GIVEREF(__pyx_v_self->__pyx_base.attr);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_self->__pyx_base.attr);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __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_2); __pyx_t_2 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_chain2->__pyx_base.attr);
  __Pyx_DECREF(__pyx_v_chain2->__pyx_base.attr);
  __pyx_v_chain2->__pyx_base.attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3199
 * 
 *         chain2.attr = copy.deepcopy(self.attr)
 *         return chain2             # <<<<<<<<<<<<<<
 * 
 *     def __reduce__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_chain2));
  __pyx_r = ((PyObject *)__pyx_v_chain2);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3187
 *         return chain2
 * 
 *     def __deepcopy__(self,memo): # deep copy everything             # <<<<<<<<<<<<<<
 *         chain2 = Transcript()
 *         chain2._set_segments(copy.deepcopy(self._segments))
 */

  /* function exit code */
  __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("plastid.genomics.roitools.Transcript.__deepcopy__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_chain2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3201
 *         return chain2
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (Transcript,tuple(),self.__getstate__())
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_7__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_6__reduce__[] = "Transcript.__reduce__(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_7__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_6__reduce__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_6__reduce__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__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);

  /* "plastid/genomics/roitools.pyx":3202
 * 
 *     def __reduce__(self):
 *         return (Transcript,tuple(),self.__getstate__())             # <<<<<<<<<<<<<<
 * 
 *     def __getstate__(self): # pickle state
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyTuple_Type)), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_getstate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __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 = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3201
 *         return chain2
 * 
 *     def __reduce__(self):             # <<<<<<<<<<<<<<
 *         return (Transcript,tuple(),self.__getstate__())
 * 
 */

  /* function exit code */
  __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("plastid.genomics.roitools.Transcript.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3204
 *         return (Transcript,tuple(),self.__getstate__())
 * 
 *     def __getstate__(self): # pickle state             # <<<<<<<<<<<<<<
 *         cdef:
 *             list segstrs  = [str(X) for X in self._segments]
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_9__getstate__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_8__getstate__[] = "Transcript.__getstate__(self)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_9__getstate__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_8__getstate__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_8__getstate__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  PyObject *__pyx_v_segstrs = 0;
  PyObject *__pyx_v_maskstrs = 0;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_v_X = 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 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getstate__", 0);

  /* "plastid/genomics/roitools.pyx":3206
 *     def __getstate__(self): # pickle state
 *         cdef:
 *             list segstrs  = [str(X) for X in self._segments]             # <<<<<<<<<<<<<<
 *             list maskstrs = [str(X) for X in self._mask_segments]
 *             dict attr = self.attr
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_self->__pyx_base._segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __pyx_v_self->__pyx_base._segments; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_X, __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 = 3206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_X);
    __Pyx_GIVEREF(__pyx_v_X);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_X);
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3206; __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_v_segstrs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3207
 *         cdef:
 *             list segstrs  = [str(X) for X in self._segments]
 *             list maskstrs = [str(X) for X in self._mask_segments]             # <<<<<<<<<<<<<<
 *             dict attr = self.attr
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(__pyx_v_self->__pyx_base._mask_segments == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = __pyx_v_self->__pyx_base._mask_segments; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  for (;;) {
    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 = 3207; __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 = 3207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_X, __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 = 3207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_X);
    __Pyx_GIVEREF(__pyx_v_X);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_X);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_maskstrs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3208
 *             list segstrs  = [str(X) for X in self._segments]
 *             list maskstrs = [str(X) for X in self._mask_segments]
 *             dict attr = self.attr             # <<<<<<<<<<<<<<
 * 
 *         return (segstrs, maskstrs, attr, self.cds_genome_start, self.cds_genome_end)
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.attr;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3210
 *             dict attr = self.attr
 * 
 *         return (segstrs, maskstrs, attr, self.cds_genome_start, self.cds_genome_end)             # <<<<<<<<<<<<<<
 * 
 *     def __setstate__(self,state): # revive state from pickling
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_segstrs);
  __Pyx_GIVEREF(__pyx_v_segstrs);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_segstrs);
  __Pyx_INCREF(__pyx_v_maskstrs);
  __Pyx_GIVEREF(__pyx_v_maskstrs);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_maskstrs);
  __Pyx_INCREF(__pyx_v_attr);
  __Pyx_GIVEREF(__pyx_v_attr);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_attr);
  __Pyx_INCREF(__pyx_v_self->cds_genome_start);
  __Pyx_GIVEREF(__pyx_v_self->cds_genome_start);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_self->cds_genome_start);
  __Pyx_INCREF(__pyx_v_self->cds_genome_end);
  __Pyx_GIVEREF(__pyx_v_self->cds_genome_end);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_self->cds_genome_end);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3204
 *         return (Transcript,tuple(),self.__getstate__())
 * 
 *     def __getstate__(self): # pickle state             # <<<<<<<<<<<<<<
 *         cdef:
 *             list segstrs  = [str(X) for X in self._segments]
 */

  /* function exit code */
  __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("plastid.genomics.roitools.Transcript.__getstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_segstrs);
  __Pyx_XDECREF(__pyx_v_maskstrs);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3212
 *         return (segstrs, maskstrs, attr, self.cds_genome_start, self.cds_genome_end)
 * 
 *     def __setstate__(self,state): # revive state from pickling             # <<<<<<<<<<<<<<
 *         cdef:
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_11__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_10__setstate__[] = "Transcript.__setstate__(self, state)";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_11__setstate__(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_10__setstate__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), ((PyObject *)__pyx_v_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_10__setstate__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_v_segs = 0;
  PyObject *__pyx_v_masks = 0;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_v_gstart = 0;
  PyObject *__pyx_v_gend = 0;
  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 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate__", 0);

  /* "plastid/genomics/roitools.pyx":3214
 *     def __setstate__(self,state): # revive state from pickling
 *         cdef:
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]             # <<<<<<<<<<<<<<
 *             list masks = [GenomicSegment.from_str(X) for X in state[1]]
 *             dict attr = state[2]
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  if (likely(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 = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(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 = 3214; __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 = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        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 = 3214; __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 = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_n_s_from_str); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_X); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_X);
      __Pyx_GIVEREF(__pyx_v_X);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_X);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __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_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __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_v_segs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3215
 *         cdef:
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]
 *             list masks = [GenomicSegment.from_str(X) for X in state[1]]             # <<<<<<<<<<<<<<
 *             dict attr = state[2]
 *             object gstart = state[3]
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(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 = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(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 = 3215; __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 = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        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 = 3215; __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 = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_X, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_n_s_from_str); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_X); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_INCREF(__pyx_v_X);
      __Pyx_GIVEREF(__pyx_v_X);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_X);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __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_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_masks = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3216
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]
 *             list masks = [GenomicSegment.from_str(X) for X in state[1]]
 *             dict attr = state[2]             # <<<<<<<<<<<<<<
 *             object gstart = state[3]
 *             object gend = state[4]
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3216; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3217
 *             list masks = [GenomicSegment.from_str(X) for X in state[1]]
 *             dict attr = state[2]
 *             object gstart = state[3]             # <<<<<<<<<<<<<<
 *             object gend = state[4]
 * 
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3217; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_gstart = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3218
 *             dict attr = state[2]
 *             object gstart = state[3]
 *             object gend = state[4]             # <<<<<<<<<<<<<<
 * 
 *         self.attr = attr
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3218; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_gend = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3220
 *             object gend = state[4]
 * 
 *         self.attr = attr             # <<<<<<<<<<<<<<
 *         self._set_segments(segs)
 *         self._set_masks(masks)
 */
  __Pyx_INCREF(__pyx_v_attr);
  __Pyx_GIVEREF(__pyx_v_attr);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.attr);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.attr);
  __pyx_v_self->__pyx_base.attr = __pyx_v_attr;

  /* "plastid/genomics/roitools.pyx":3221
 * 
 *         self.attr = attr
 *         self._set_segments(segs)             # <<<<<<<<<<<<<<
 *         self._set_masks(masks)
 *         self.cds_genome_start = gstart
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._set_segments(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_segs); if (unlikely(__pyx_t_9 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3222
 *         self.attr = attr
 *         self._set_segments(segs)
 *         self._set_masks(masks)             # <<<<<<<<<<<<<<
 *         self.cds_genome_start = gstart
 *         self.cds_genome_end = gend
 */
  __pyx_t_9 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base._set_masks(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_masks); if (unlikely(__pyx_t_9 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3223
 *         self._set_segments(segs)
 *         self._set_masks(masks)
 *         self.cds_genome_start = gstart             # <<<<<<<<<<<<<<
 *         self.cds_genome_end = gend
 *         if gstart is not None and gend is not None:
 */
  __Pyx_INCREF(__pyx_v_gstart);
  __Pyx_GIVEREF(__pyx_v_gstart);
  __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
  __Pyx_DECREF(__pyx_v_self->cds_genome_start);
  __pyx_v_self->cds_genome_start = __pyx_v_gstart;

  /* "plastid/genomics/roitools.pyx":3224
 *         self._set_masks(masks)
 *         self.cds_genome_start = gstart
 *         self.cds_genome_end = gend             # <<<<<<<<<<<<<<
 *         if gstart is not None and gend is not None:
 *             self._update_cds()
 */
  __Pyx_INCREF(__pyx_v_gend);
  __Pyx_GIVEREF(__pyx_v_gend);
  __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
  __Pyx_DECREF(__pyx_v_self->cds_genome_end);
  __pyx_v_self->cds_genome_end = __pyx_v_gend;

  /* "plastid/genomics/roitools.pyx":3225
 *         self.cds_genome_start = gstart
 *         self.cds_genome_end = gend
 *         if gstart is not None and gend is not None:             # <<<<<<<<<<<<<<
 *             self._update_cds()
 *         else:
 */
  __pyx_t_10 = (__pyx_v_gstart != Py_None);
  __pyx_t_11 = (__pyx_t_10 != 0);
  if (__pyx_t_11) {
  } else {
    __pyx_t_9 = __pyx_t_11;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_11 = (__pyx_v_gend != Py_None);
  __pyx_t_10 = (__pyx_t_11 != 0);
  __pyx_t_9 = __pyx_t_10;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_9) {

    /* "plastid/genomics/roitools.pyx":3226
 *         self.cds_genome_end = gend
 *         if gstart is not None and gend is not None:
 *             self._update_cds()             # <<<<<<<<<<<<<<
 *         else:
 *             self.cds_start = None
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->_update_cds(__pyx_v_self); if (unlikely(__pyx_t_9 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3225
 *         self.cds_genome_start = gstart
 *         self.cds_genome_end = gend
 *         if gstart is not None and gend is not None:             # <<<<<<<<<<<<<<
 *             self._update_cds()
 *         else:
 */
    goto __pyx_L7;
  }

  /* "plastid/genomics/roitools.pyx":3228
 *             self._update_cds()
 *         else:
 *             self.cds_start = None             # <<<<<<<<<<<<<<
 *             self.cds_end = None
 * 
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3229
 *         else:
 *             self.cds_start = None
 *             self.cds_end = None             # <<<<<<<<<<<<<<
 * 
 *     def __richcmp__(self, object other, int cmpval):
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_end);
    __Pyx_DECREF(__pyx_v_self->cds_end);
    __pyx_v_self->cds_end = Py_None;
  }
  __pyx_L7:;

  /* "plastid/genomics/roitools.pyx":3212
 *         return (segstrs, maskstrs, attr, self.cds_genome_start, self.cds_genome_end)
 * 
 *     def __setstate__(self,state): # revive state from pickling             # <<<<<<<<<<<<<<
 *         cdef:
 *             list segs  = [GenomicSegment.from_str(X) for X in state[0]]
 */

  /* function exit code */
  __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_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.__setstate__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_segs);
  __Pyx_XDECREF(__pyx_v_masks);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF(__pyx_v_gstart);
  __Pyx_XDECREF(__pyx_v_gend);
  __Pyx_XDECREF(__pyx_v_X);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3231
 *             self.cds_end = None
 * 
 *     def __richcmp__(self, object other, int cmpval):             # <<<<<<<<<<<<<<
 *         """Test whether `self` and `other` are equal or unequal. Equality is defined as
 *         identity of positions, chromosomes, and strands. Two |SegmentChain| with
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_13__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmpval); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_13__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmpval) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_12__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((int)__pyx_v_cmpval));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_12__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_cmpval) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  enum __pyx_t_7plastid_8genomics_8c_common_ExBool __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("__richcmp__", 0);

  /* "plastid/genomics/roitools.pyx":3245
 *         bool
 *         """
 *         if isinstance(other,Transcript):             # <<<<<<<<<<<<<<
 *             return transcript_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_Transcript); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3246
 *         """
 *         if isinstance(other,Transcript):
 *             return transcript_richcmp(self,other,cmpval) == true             # <<<<<<<<<<<<<<
 *         elif isinstance(other,GenomicSegment):
 *             return transcript_richcmp(self,SegmentChain(other),cmpval) == true
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_self) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_7plastid_8genomics_8roitools_Transcript))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_Transcript))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_transcript_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_other), __pyx_v_cmpval); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":3245
 *         bool
 *         """
 *         if isinstance(other,Transcript):             # <<<<<<<<<<<<<<
 *             return transcript_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):
 */
  }

  /* "plastid/genomics/roitools.pyx":3247
 *         if isinstance(other,Transcript):
 *             return transcript_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return transcript_richcmp(self,SegmentChain(other),cmpval) == true
 *         else:
 */
  __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_other, __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment); 
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "plastid/genomics/roitools.pyx":3248
 *             return transcript_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):
 *             return transcript_richcmp(self,SegmentChain(other),cmpval) == true             # <<<<<<<<<<<<<<
 *         else:
 *             raise TypeError("SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.")
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_self) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_self, __pyx_ptype_7plastid_8genomics_8roitools_Transcript))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_other);
    __Pyx_GIVEREF(__pyx_v_other);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_other);
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_7plastid_8genomics_8roitools_Transcript)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_transcript_richcmp(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_t_5), __pyx_v_cmpval); if (unlikely(__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_bool_exception)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyBool_FromLong((__pyx_t_3 == __pyx_e_7plastid_8genomics_8c_common_true)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":3247
 *         if isinstance(other,Transcript):
 *             return transcript_richcmp(self,other,cmpval) == true
 *         elif isinstance(other,GenomicSegment):             # <<<<<<<<<<<<<<
 *             return transcript_richcmp(self,SegmentChain(other),cmpval) == true
 *         else:
 */
  }

  /* "plastid/genomics/roitools.pyx":3250
 *             return transcript_richcmp(self,SegmentChain(other),cmpval) == true
 *         else:
 *             raise TypeError("SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.")             # <<<<<<<<<<<<<<
 * 
 *     property cds_start:
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3250; __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 = 3250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":3231
 *             self.cds_end = None
 * 
 *     def __richcmp__(self, object other, int cmpval):             # <<<<<<<<<<<<<<
 *         """Test whether `self` and `other` are equal or unequal. Equality is defined as
 *         identity of positions, chromosomes, and strands. Two |SegmentChain| with
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3257
 *         `self.cds_genome_end` to None
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.cds_start
 *         def __set__(self,val):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_9cds_start_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_9cds_start_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_9cds_start___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_9cds_start___get__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "plastid/genomics/roitools.pyx":3258
 *         """
 *         def __get__(self):
 *             return self.cds_start             # <<<<<<<<<<<<<<
 *         def __set__(self,val):
 *             cdef object end = self.cds_end
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->cds_start);
  __pyx_r = __pyx_v_self->cds_start;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3257
 *         `self.cds_genome_end` to None
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.cds_start
 *         def __set__(self,val):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3259
 *         def __get__(self):
 *             return self.cds_start
 *         def __set__(self,val):             # <<<<<<<<<<<<<<
 *             cdef object end = self.cds_end
 *             if val is not None and end is not None:
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_9cds_start_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_9cds_start_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_9cds_start_2__set__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), ((PyObject *)__pyx_v_val));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript_9cds_start_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_val) {
  PyObject *__pyx_v_end = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("__set__", 0);

  /* "plastid/genomics/roitools.pyx":3260
 *             return self.cds_start
 *         def __set__(self,val):
 *             cdef object end = self.cds_end             # <<<<<<<<<<<<<<
 *             if val is not None and end is not None:
 *                 if val > end:
 */
  __pyx_t_1 = __pyx_v_self->cds_end;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3261
 *         def __set__(self,val):
 *             cdef object end = self.cds_end
 *             if val is not None and end is not None:             # <<<<<<<<<<<<<<
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be <= cds_end (%s)" % (self,val,end))
 */
  __pyx_t_3 = (__pyx_v_val != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_end != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3262
 *             cdef object end = self.cds_end
 *             if val is not None and end is not None:
 *                 if val > end:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be <= cds_end (%s)" % (self,val,end))
 *                 if val < 0:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_val, __pyx_v_end, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3262; __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 = 3262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":3263
 *             if val is not None and end is not None:
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be <= cds_end (%s)" % (self,val,end))             # <<<<<<<<<<<<<<
 *                 if val < 0:
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be >= 0" % (self,val))
 */
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_val);
      __Pyx_GIVEREF(__pyx_v_val);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_val);
      __Pyx_INCREF(__pyx_v_end);
      __Pyx_GIVEREF(__pyx_v_end);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
      __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Transcript_s_cds_start_s_must_be, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __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 = 3263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":3262
 *             cdef object end = self.cds_end
 *             if val is not None and end is not None:
 *                 if val > end:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be <= cds_end (%s)" % (self,val,end))
 *                 if val < 0:
 */
    }

    /* "plastid/genomics/roitools.pyx":3264
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be <= cds_end (%s)" % (self,val,end))
 *                 if val < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be >= 0" % (self,val))
 *             self.cds_start = val
 */
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_val, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":3265
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be <= cds_end (%s)" % (self,val,end))
 *                 if val < 0:
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be >= 0" % (self,val))             # <<<<<<<<<<<<<<
 *             self.cds_start = val
 *             if val is None:
 */
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_val);
      __Pyx_GIVEREF(__pyx_v_val);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_val);
      __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Transcript_s_cds_start_s_must_be_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__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 = 3265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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 = 3265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":3264
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be <= cds_end (%s)" % (self,val,end))
 *                 if val < 0:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be >= 0" % (self,val))
 *             self.cds_start = val
 */
    }

    /* "plastid/genomics/roitools.pyx":3261
 *         def __set__(self,val):
 *             cdef object end = self.cds_end
 *             if val is not None and end is not None:             # <<<<<<<<<<<<<<
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be <= cds_end (%s)" % (self,val,end))
 */
  }

  /* "plastid/genomics/roitools.pyx":3266
 *                 if val < 0:
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be >= 0" % (self,val))
 *             self.cds_start = val             # <<<<<<<<<<<<<<
 *             if val is None:
 *                 self.cds_end = None
 */
  __Pyx_INCREF(__pyx_v_val);
  __Pyx_GIVEREF(__pyx_v_val);
  __Pyx_GOTREF(__pyx_v_self->cds_start);
  __Pyx_DECREF(__pyx_v_self->cds_start);
  __pyx_v_self->cds_start = __pyx_v_val;

  /* "plastid/genomics/roitools.pyx":3267
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be >= 0" % (self,val))
 *             self.cds_start = val
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 self.cds_end = None
 *                 self.cds_genome_start = None
 */
  __pyx_t_2 = (__pyx_v_val == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3268
 *             self.cds_start = val
 *             if val is None:
 *                 self.cds_end = None             # <<<<<<<<<<<<<<
 *                 self.cds_genome_start = None
 *                 self.cds_genome_end = None
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_end);
    __Pyx_DECREF(__pyx_v_self->cds_end);
    __pyx_v_self->cds_end = Py_None;

    /* "plastid/genomics/roitools.pyx":3269
 *             if val is None:
 *                 self.cds_end = None
 *                 self.cds_genome_start = None             # <<<<<<<<<<<<<<
 *                 self.cds_genome_end = None
 *             else:
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
    __Pyx_DECREF(__pyx_v_self->cds_genome_start);
    __pyx_v_self->cds_genome_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3270
 *                 self.cds_end = None
 *                 self.cds_genome_start = None
 *                 self.cds_genome_end = None             # <<<<<<<<<<<<<<
 *             else:
 *                 self._update_from_cds_start()
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
    __Pyx_DECREF(__pyx_v_self->cds_genome_end);
    __pyx_v_self->cds_genome_end = Py_None;

    /* "plastid/genomics/roitools.pyx":3267
 *                     raise ValueError("Transcript '%s': cds_start (%s) must be >= 0" % (self,val))
 *             self.cds_start = val
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 self.cds_end = None
 *                 self.cds_genome_start = None
 */
    goto __pyx_L8;
  }

  /* "plastid/genomics/roitools.pyx":3272
 *                 self.cds_genome_end = None
 *             else:
 *                 self._update_from_cds_start()             # <<<<<<<<<<<<<<
 * 
 *     property cds_end:
 */
  /*else*/ {
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->_update_from_cds_start(__pyx_v_self); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L8:;

  /* "plastid/genomics/roitools.pyx":3259
 *         def __get__(self):
 *             return self.cds_start
 *         def __set__(self,val):             # <<<<<<<<<<<<<<
 *             cdef object end = self.cds_end
 *             if val is not None and end is not None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.cds_start.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3279
 *         `self.cds_genome_end` to None
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.cds_end
 *         def __set__(self,val):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_7cds_end_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_7cds_end_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_7cds_end___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_7cds_end___get__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "plastid/genomics/roitools.pyx":3280
 *         """
 *         def __get__(self):
 *             return self.cds_end             # <<<<<<<<<<<<<<
 *         def __set__(self,val):
 *             cdef object start = self.cds_start
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->cds_end);
  __pyx_r = __pyx_v_self->cds_end;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3279
 *         `self.cds_genome_end` to None
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.cds_end
 *         def __set__(self,val):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3281
 *         def __get__(self):
 *             return self.cds_end
 *         def __set__(self,val):             # <<<<<<<<<<<<<<
 *             cdef object start = self.cds_start
 *             if val is not None and start is not None:
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_7cds_end_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_7cds_end_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_7cds_end_2__set__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), ((PyObject *)__pyx_v_val));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript_7cds_end_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_val) {
  PyObject *__pyx_v_start = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("__set__", 0);

  /* "plastid/genomics/roitools.pyx":3282
 *             return self.cds_end
 *         def __set__(self,val):
 *             cdef object start = self.cds_start             # <<<<<<<<<<<<<<
 *             if val is not None and start is not None:
 *                 if val < start:
 */
  __pyx_t_1 = __pyx_v_self->cds_start;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_start = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3283
 *         def __set__(self,val):
 *             cdef object start = self.cds_start
 *             if val is not None and start is not None:             # <<<<<<<<<<<<<<
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be >= cds_start (%s)" % (self,val,start))
 */
  __pyx_t_3 = (__pyx_v_val != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_start != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3284
 *             cdef object start = self.cds_start
 *             if val is not None and start is not None:
 *                 if val < start:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be >= cds_start (%s)" % (self,val,start))
 *                 if val > self.length:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_val, __pyx_v_start, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3284; __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 = 3284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":3285
 *             if val is not None and start is not None:
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be >= cds_start (%s)" % (self,val,start))             # <<<<<<<<<<<<<<
 *                 if val > self.length:
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be <= self.length (%s)" % (self,val,self.length))
 */
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_val);
      __Pyx_GIVEREF(__pyx_v_val);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_val);
      __Pyx_INCREF(__pyx_v_start);
      __Pyx_GIVEREF(__pyx_v_start);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_start);
      __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Transcript_s_cds_end_s_must_be_c, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __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 = 3285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":3284
 *             cdef object start = self.cds_start
 *             if val is not None and start is not None:
 *                 if val < start:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be >= cds_start (%s)" % (self,val,start))
 *                 if val > self.length:
 */
    }

    /* "plastid/genomics/roitools.pyx":3286
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be >= cds_start (%s)" % (self,val,start))
 *                 if val > self.length:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be <= self.length (%s)" % (self,val,self.length))
 *             self.cds_end = val
 */
    __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_self->__pyx_base.length); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_val, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":3287
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be >= cds_start (%s)" % (self,val,start))
 *                 if val > self.length:
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be <= self.length (%s)" % (self,val,self.length))             # <<<<<<<<<<<<<<
 *             self.cds_end = val
 *             if val is None:
 */
      __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_self->__pyx_base.length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __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 = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_val);
      __Pyx_GIVEREF(__pyx_v_val);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_val);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Transcript_s_cds_end_s_must_be_s, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__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 = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 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 = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":3286
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be >= cds_start (%s)" % (self,val,start))
 *                 if val > self.length:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be <= self.length (%s)" % (self,val,self.length))
 *             self.cds_end = val
 */
    }

    /* "plastid/genomics/roitools.pyx":3283
 *         def __set__(self,val):
 *             cdef object start = self.cds_start
 *             if val is not None and start is not None:             # <<<<<<<<<<<<<<
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be >= cds_start (%s)" % (self,val,start))
 */
  }

  /* "plastid/genomics/roitools.pyx":3288
 *                 if val > self.length:
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be <= self.length (%s)" % (self,val,self.length))
 *             self.cds_end = val             # <<<<<<<<<<<<<<
 *             if val is None:
 *                 self.cds_start = None
 */
  __Pyx_INCREF(__pyx_v_val);
  __Pyx_GIVEREF(__pyx_v_val);
  __Pyx_GOTREF(__pyx_v_self->cds_end);
  __Pyx_DECREF(__pyx_v_self->cds_end);
  __pyx_v_self->cds_end = __pyx_v_val;

  /* "plastid/genomics/roitools.pyx":3289
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be <= self.length (%s)" % (self,val,self.length))
 *             self.cds_end = val
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 self.cds_start = None
 *                 self.cds_genome_start = None
 */
  __pyx_t_2 = (__pyx_v_val == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3290
 *             self.cds_end = val
 *             if val is None:
 *                 self.cds_start = None             # <<<<<<<<<<<<<<
 *                 self.cds_genome_start = None
 *                 self.cds_genome_end = None
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3291
 *             if val is None:
 *                 self.cds_start = None
 *                 self.cds_genome_start = None             # <<<<<<<<<<<<<<
 *                 self.cds_genome_end = None
 *             else:
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
    __Pyx_DECREF(__pyx_v_self->cds_genome_start);
    __pyx_v_self->cds_genome_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3292
 *                 self.cds_start = None
 *                 self.cds_genome_start = None
 *                 self.cds_genome_end = None             # <<<<<<<<<<<<<<
 *             else:
 *                 self._update_from_cds_end()
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
    __Pyx_DECREF(__pyx_v_self->cds_genome_end);
    __pyx_v_self->cds_genome_end = Py_None;

    /* "plastid/genomics/roitools.pyx":3289
 *                     raise ValueError("Transcript '%s': cds_end (%s) must be <= self.length (%s)" % (self,val,self.length))
 *             self.cds_end = val
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 self.cds_start = None
 *                 self.cds_genome_start = None
 */
    goto __pyx_L8;
  }

  /* "plastid/genomics/roitools.pyx":3294
 *                 self.cds_genome_end = None
 *             else:
 *                 self._update_from_cds_end()             # <<<<<<<<<<<<<<
 * 
 *     property cds_genome_start:
 */
  /*else*/ {
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->_update_from_cds_end(__pyx_v_self); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L8:;

  /* "plastid/genomics/roitools.pyx":3281
 *         def __get__(self):
 *             return self.cds_end
 *         def __set__(self,val):             # <<<<<<<<<<<<<<
 *             cdef object start = self.cds_start
 *             if val is not None and start is not None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.cds_end.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3302
 *         `self.cds_genome_end` to None
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.cds_genome_start
 *         def __set__(self, val):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start___get__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "plastid/genomics/roitools.pyx":3303
 *         """
 *         def __get__(self):
 *             return self.cds_genome_start             # <<<<<<<<<<<<<<
 *         def __set__(self, val):
 *             cdef object end = self.cds_genome_end
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->cds_genome_start);
  __pyx_r = __pyx_v_self->cds_genome_start;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3302
 *         `self.cds_genome_end` to None
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.cds_genome_start
 *         def __set__(self, val):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3304
 *         def __get__(self):
 *             return self.cds_genome_start
 *         def __set__(self, val):             # <<<<<<<<<<<<<<
 *             cdef object end = self.cds_genome_end
 *             if val is not None and end is not None:
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_2__set__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), ((PyObject *)__pyx_v_val));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_val) {
  PyObject *__pyx_v_end = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("__set__", 0);

  /* "plastid/genomics/roitools.pyx":3305
 *             return self.cds_genome_start
 *         def __set__(self, val):
 *             cdef object end = self.cds_genome_end             # <<<<<<<<<<<<<<
 *             if val is not None and end is not None:
 *                 if val > end:
 */
  __pyx_t_1 = __pyx_v_self->cds_genome_end;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3306
 *         def __set__(self, val):
 *             cdef object end = self.cds_genome_end
 *             if val is not None and end is not None:             # <<<<<<<<<<<<<<
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)" % (self,val,end))
 */
  __pyx_t_3 = (__pyx_v_val != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_end != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3307
 *             cdef object end = self.cds_genome_end
 *             if val is not None and end is not None:
 *                 if val > end:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)" % (self,val,end))
 *             self.cds_genome_start = val
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_val, __pyx_v_end, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3307; __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 = 3307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":3308
 *             if val is not None and end is not None:
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)" % (self,val,end))             # <<<<<<<<<<<<<<
 *             self.cds_genome_start = val
 *             if val is None:
 */
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_val);
      __Pyx_GIVEREF(__pyx_v_val);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_val);
      __Pyx_INCREF(__pyx_v_end);
      __Pyx_GIVEREF(__pyx_v_end);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
      __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Transcript_s_cds_genome_start_s, __pyx_t_1); if (unlikely(!__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_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__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_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":3307
 *             cdef object end = self.cds_genome_end
 *             if val is not None and end is not None:
 *                 if val > end:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)" % (self,val,end))
 *             self.cds_genome_start = val
 */
    }

    /* "plastid/genomics/roitools.pyx":3306
 *         def __set__(self, val):
 *             cdef object end = self.cds_genome_end
 *             if val is not None and end is not None:             # <<<<<<<<<<<<<<
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)" % (self,val,end))
 */
  }

  /* "plastid/genomics/roitools.pyx":3309
 *                 if val > end:
 *                     raise ValueError("Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)" % (self,val,end))
 *             self.cds_genome_start = val             # <<<<<<<<<<<<<<
 *             if val is None:
 *                 self.cds_genome_end = None
 */
  __Pyx_INCREF(__pyx_v_val);
  __Pyx_GIVEREF(__pyx_v_val);
  __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
  __Pyx_DECREF(__pyx_v_self->cds_genome_start);
  __pyx_v_self->cds_genome_start = __pyx_v_val;

  /* "plastid/genomics/roitools.pyx":3310
 *                     raise ValueError("Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)" % (self,val,end))
 *             self.cds_genome_start = val
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 self.cds_genome_end = None
 *                 self.cds_start = None
 */
  __pyx_t_2 = (__pyx_v_val == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3311
 *             self.cds_genome_start = val
 *             if val is None:
 *                 self.cds_genome_end = None             # <<<<<<<<<<<<<<
 *                 self.cds_start = None
 *                 self.cds_end = None
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
    __Pyx_DECREF(__pyx_v_self->cds_genome_end);
    __pyx_v_self->cds_genome_end = Py_None;

    /* "plastid/genomics/roitools.pyx":3312
 *             if val is None:
 *                 self.cds_genome_end = None
 *                 self.cds_start = None             # <<<<<<<<<<<<<<
 *                 self.cds_end = None
 *             else:
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3313
 *                 self.cds_genome_end = None
 *                 self.cds_start = None
 *                 self.cds_end = None             # <<<<<<<<<<<<<<
 *             else:
 *                 self._update_from_cds_genome_start()
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_end);
    __Pyx_DECREF(__pyx_v_self->cds_end);
    __pyx_v_self->cds_end = Py_None;

    /* "plastid/genomics/roitools.pyx":3310
 *                     raise ValueError("Transcript '%s': cds_genome_start (%s) must be <= cds_genome_end (%s)" % (self,val,end))
 *             self.cds_genome_start = val
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 self.cds_genome_end = None
 *                 self.cds_start = None
 */
    goto __pyx_L7;
  }

  /* "plastid/genomics/roitools.pyx":3315
 *                 self.cds_end = None
 *             else:
 *                 self._update_from_cds_genome_start()             # <<<<<<<<<<<<<<
 * 
 *     property cds_genome_end:
 */
  /*else*/ {
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->_update_from_cds_genome_start(__pyx_v_self); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L7:;

  /* "plastid/genomics/roitools.pyx":3304
 *         def __get__(self):
 *             return self.cds_genome_start
 *         def __set__(self, val):             # <<<<<<<<<<<<<<
 *             cdef object end = self.cds_genome_end
 *             if val is not None and end is not None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.cds_genome_start.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3323
 *         and `self.cds_genome_start` to None
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.cds_genome_end
 *         def __set__(self, val):
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end___get__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end___get__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "plastid/genomics/roitools.pyx":3324
 *         """
 *         def __get__(self):
 *             return self.cds_genome_end             # <<<<<<<<<<<<<<
 *         def __set__(self, val):
 *             cdef object start = self.cds_genome_start
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->cds_genome_end);
  __pyx_r = __pyx_v_self->cds_genome_end;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3323
 *         and `self.cds_genome_start` to None
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.cds_genome_end
 *         def __set__(self, val):
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3325
 *         def __get__(self):
 *             return self.cds_genome_end
 *         def __set__(self, val):             # <<<<<<<<<<<<<<
 *             cdef object start = self.cds_genome_start
 *             if val is not None and start is not None:
 */

/* Python wrapper */
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
static int __pyx_pw_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_2__set__(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), ((PyObject *)__pyx_v_val));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_2__set__(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_val) {
  PyObject *__pyx_v_start = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("__set__", 0);

  /* "plastid/genomics/roitools.pyx":3326
 *             return self.cds_genome_end
 *         def __set__(self, val):
 *             cdef object start = self.cds_genome_start             # <<<<<<<<<<<<<<
 *             if val is not None and start is not None:
 *                 if val < start:
 */
  __pyx_t_1 = __pyx_v_self->cds_genome_start;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_start = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3327
 *         def __set__(self, val):
 *             cdef object start = self.cds_genome_start
 *             if val is not None and start is not None:             # <<<<<<<<<<<<<<
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)" % (self,val,start))
 */
  __pyx_t_3 = (__pyx_v_val != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_start != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3328
 *             cdef object start = self.cds_genome_start
 *             if val is not None and start is not None:
 *                 if val < start:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)" % (self,val,start))
 *             self.cds_genome_end = val
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_val, __pyx_v_start, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __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 = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {

      /* "plastid/genomics/roitools.pyx":3329
 *             if val is not None and start is not None:
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)" % (self,val,start))             # <<<<<<<<<<<<<<
 *             self.cds_genome_end = val
 *             if val is None:
 */
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
      __Pyx_INCREF(__pyx_v_val);
      __Pyx_GIVEREF(__pyx_v_val);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_val);
      __Pyx_INCREF(__pyx_v_start);
      __Pyx_GIVEREF(__pyx_v_start);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_start);
      __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Transcript_s_cds_genome_end_s_mu, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __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 = 3329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":3328
 *             cdef object start = self.cds_genome_start
 *             if val is not None and start is not None:
 *                 if val < start:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)" % (self,val,start))
 *             self.cds_genome_end = val
 */
    }

    /* "plastid/genomics/roitools.pyx":3327
 *         def __set__(self, val):
 *             cdef object start = self.cds_genome_start
 *             if val is not None and start is not None:             # <<<<<<<<<<<<<<
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)" % (self,val,start))
 */
  }

  /* "plastid/genomics/roitools.pyx":3330
 *                 if val < start:
 *                     raise ValueError("Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)" % (self,val,start))
 *             self.cds_genome_end = val             # <<<<<<<<<<<<<<
 *             if val is None:
 *                 self.cds_genome_start = None
 */
  __Pyx_INCREF(__pyx_v_val);
  __Pyx_GIVEREF(__pyx_v_val);
  __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
  __Pyx_DECREF(__pyx_v_self->cds_genome_end);
  __pyx_v_self->cds_genome_end = __pyx_v_val;

  /* "plastid/genomics/roitools.pyx":3331
 *                     raise ValueError("Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)" % (self,val,start))
 *             self.cds_genome_end = val
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 self.cds_genome_start = None
 *                 self.cds_start = None
 */
  __pyx_t_2 = (__pyx_v_val == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3332
 *             self.cds_genome_end = val
 *             if val is None:
 *                 self.cds_genome_start = None             # <<<<<<<<<<<<<<
 *                 self.cds_start = None
 *                 self.cds_end = None
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
    __Pyx_DECREF(__pyx_v_self->cds_genome_start);
    __pyx_v_self->cds_genome_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3333
 *             if val is None:
 *                 self.cds_genome_start = None
 *                 self.cds_start = None             # <<<<<<<<<<<<<<
 *                 self.cds_end = None
 *             else:
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = Py_None;

    /* "plastid/genomics/roitools.pyx":3334
 *                 self.cds_genome_start = None
 *                 self.cds_start = None
 *                 self.cds_end = None             # <<<<<<<<<<<<<<
 *             else:
 *                 self._update_from_cds_genome_end()
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->cds_end);
    __Pyx_DECREF(__pyx_v_self->cds_end);
    __pyx_v_self->cds_end = Py_None;

    /* "plastid/genomics/roitools.pyx":3331
 *                     raise ValueError("Transcript '%s': cds_genome_end (%s) must be >= cds_genome_start (%s)" % (self,val,start))
 *             self.cds_genome_end = val
 *             if val is None:             # <<<<<<<<<<<<<<
 *                 self.cds_genome_start = None
 *                 self.cds_start = None
 */
    goto __pyx_L7;
  }

  /* "plastid/genomics/roitools.pyx":3336
 *                 self.cds_end = None
 *             else:
 *                 self._update_from_cds_genome_end()             # <<<<<<<<<<<<<<
 * 
 *     # TODO: create explicit unit test
 */
  /*else*/ {
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->_update_from_cds_genome_end(__pyx_v_self); if (unlikely(__pyx_t_3 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L7:;

  /* "plastid/genomics/roitools.pyx":3325
 *         def __get__(self):
 *             return self.cds_genome_end
 *         def __set__(self, val):             # <<<<<<<<<<<<<<
 *             cdef object start = self.cds_genome_start
 *             if val is not None and start is not None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.cds_genome_end.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3339
 * 
 *     # TODO: create explicit unit test
 *     cdef bint _update_cds(self) except False:             # <<<<<<<<<<<<<<
 *         """Generate `self.cds_start` and `self.cds_end` from `self.cds_genome_start` and `self.cds_genome_end`
 *         AFTER verifying that these values are not None
 */

static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_cds(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_span = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_strand;
  CYTHON_UNUSED PyObject *__pyx_v_chrom = 0;
  long __pyx_v_cds_genome_start;
  long __pyx_v_cds_genome_end;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_t_2;
  long __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  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("_update_cds", 0);

  /* "plastid/genomics/roitools.pyx":3344
 *         """
 *         cdef:
 *             GenomicSegment span = self.spanning_segment             # <<<<<<<<<<<<<<
 *             Strand strand = span.c_strand
 *             str chrom = span.chrom
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_span = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3345
 *         cdef:
 *             GenomicSegment span = self.spanning_segment
 *             Strand strand = span.c_strand             # <<<<<<<<<<<<<<
 *             str chrom = span.chrom
 *             long cds_genome_start = self.cds_genome_start
 */
  __pyx_t_2 = __pyx_v_span->c_strand;
  __pyx_v_strand = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":3346
 *             GenomicSegment span = self.spanning_segment
 *             Strand strand = span.c_strand
 *             str chrom = span.chrom             # <<<<<<<<<<<<<<
 *             long cds_genome_start = self.cds_genome_start
 *             long cds_genome_end   = self.cds_genome_end
 */
  __pyx_t_1 = __pyx_v_span->chrom;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_chrom = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3347
 *             Strand strand = span.c_strand
 *             str chrom = span.chrom
 *             long cds_genome_start = self.cds_genome_start             # <<<<<<<<<<<<<<
 *             long cds_genome_end   = self.cds_genome_end
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_As_long(__pyx_v_self->cds_genome_start); if (unlikely((__pyx_t_3 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cds_genome_start = __pyx_t_3;

  /* "plastid/genomics/roitools.pyx":3348
 *             str chrom = span.chrom
 *             long cds_genome_start = self.cds_genome_start
 *             long cds_genome_end   = self.cds_genome_end             # <<<<<<<<<<<<<<
 * 
 *         if strand == forward_strand:
 */
  __pyx_t_3 = __Pyx_PyInt_As_long(__pyx_v_self->cds_genome_end); if (unlikely((__pyx_t_3 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cds_genome_end = __pyx_t_3;

  /* "plastid/genomics/roitools.pyx":3350
 *             long cds_genome_end   = self.cds_genome_end
 * 
 *         if strand == forward_strand:             # <<<<<<<<<<<<<<
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_start,True)
 * 
 */
  __pyx_t_4 = ((__pyx_v_strand == __pyx_e_7plastid_8genomics_8c_common_forward_strand) != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":3351
 * 
 *         if strand == forward_strand:
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_start,True)             # <<<<<<<<<<<<<<
 * 
 *             # this is in a try-catch because if the half-open cds_end coincides
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_cds_genome_start, 1); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3355
 *             # this is in a try-catch because if the half-open cds_end coincides
 *             # with the end of an exon, it will not be in the end-inclusive position
 *             try:             # <<<<<<<<<<<<<<
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)
 *             except KeyError:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      /*try:*/ {

        /* "plastid/genomics/roitools.pyx":3356
 *             # with the end of an exon, it will not be in the end-inclusive position
 *             try:
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)             # <<<<<<<<<<<<<<
 *             except KeyError:
 *                 # minus one, plus one corrections because end-exclusive genome
 */
        __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_cds_genome_end, 1); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_v_self->cds_end);
        __Pyx_DECREF(__pyx_v_self->cds_end);
        __pyx_v_self->cds_end = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "plastid/genomics/roitools.pyx":3355
 *             # this is in a try-catch because if the half-open cds_end coincides
 *             # with the end of an exon, it will not be in the end-inclusive position
 *             try:             # <<<<<<<<<<<<<<
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)
 *             except KeyError:
 */
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "plastid/genomics/roitools.pyx":3357
 *             try:
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)
 *             except KeyError:             # <<<<<<<<<<<<<<
 *                 # minus one, plus one corrections because end-exclusive genome
 *                 # position will not be in position hash if it coincides with
 */
      __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
      if (__pyx_t_8) {
        __Pyx_AddTraceback("plastid.genomics.roitools.Transcript._update_cds", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3357; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_10);

        /* "plastid/genomics/roitools.pyx":3361
 *                 # position will not be in position hash if it coincides with
 *                 # the end of any exon
 *                 self.cds_end   = 1 + self.c_get_segmentchain_coordinate(cds_genome_end - 1,True)             # <<<<<<<<<<<<<<
 *         else:
 *             # likewise for minus-strand
 */
        __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), (__pyx_v_cds_genome_end - 1), 1); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __pyx_t_11 = __Pyx_PyInt_From_long((1 + __pyx_t_3)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __Pyx_GOTREF(__pyx_v_self->cds_end);
        __Pyx_DECREF(__pyx_v_self->cds_end);
        __pyx_v_self->cds_end = __pyx_t_11;
        __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L5_exception_handled;
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "plastid/genomics/roitools.pyx":3355
 *             # this is in a try-catch because if the half-open cds_end coincides
 *             # with the end of an exon, it will not be in the end-inclusive position
 *             try:             # <<<<<<<<<<<<<<
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)
 *             except KeyError:
 */
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      __pyx_L11_try_end:;
    }

    /* "plastid/genomics/roitools.pyx":3350
 *             long cds_genome_end   = self.cds_genome_end
 * 
 *         if strand == forward_strand:             # <<<<<<<<<<<<<<
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_start,True)
 * 
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":3367
 *             # have been thoroughly tested by examining BED files exported
 *             # for this purpose
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_end - 1,  True)             # <<<<<<<<<<<<<<
 *             self.cds_end   = 1 + self.c_get_segmentchain_coordinate(cds_genome_start,True)
 * 
 */
  /*else*/ {
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), (__pyx_v_cds_genome_end - 1), 1); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_t_3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_10);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = __pyx_t_10;
    __pyx_t_10 = 0;

    /* "plastid/genomics/roitools.pyx":3368
 *             # for this purpose
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_end - 1,  True)
 *             self.cds_end   = 1 + self.c_get_segmentchain_coordinate(cds_genome_start,True)             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_cds_genome_start, 1); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_From_long((1 + __pyx_t_3)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_10);
    __Pyx_GOTREF(__pyx_v_self->cds_end);
    __Pyx_DECREF(__pyx_v_self->cds_end);
    __pyx_v_self->cds_end = __pyx_t_10;
    __pyx_t_10 = 0;
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":3370
 *             self.cds_end   = 1 + self.c_get_segmentchain_coordinate(cds_genome_start,True)
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef bint _update_from_cds_start(self) except False:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3339
 * 
 *     # TODO: create explicit unit test
 *     cdef bint _update_cds(self) except False:             # <<<<<<<<<<<<<<
 *         """Generate `self.cds_start` and `self.cds_end` from `self.cds_genome_start` and `self.cds_genome_end`
 *         AFTER verifying that these values are not None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript._update_cds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_span);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3372
 *         return True
 * 
 *     cdef bint _update_from_cds_start(self) except False:             # <<<<<<<<<<<<<<
 *         cdef:
 *             long cds_start = <long>self.cds_start
 */

static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_start(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  long __pyx_v_cds_start;
  __Pyx_memviewslice __pyx_v_phash = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_update_from_cds_start", 0);

  /* "plastid/genomics/roitools.pyx":3374
 *     cdef bint _update_from_cds_start(self) except False:
 *         cdef:
 *             long cds_start = <long>self.cds_start             # <<<<<<<<<<<<<<
 *             long [:] phash = self._position_hash
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_As_long(__pyx_v_self->cds_start); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cds_start = ((long)__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3375
 *         cdef:
 *             long cds_start = <long>self.cds_start
 *             long [:] phash = self._position_hash             # <<<<<<<<<<<<<<
 * 
 *         if self.spanning_segment.c_strand == forward_strand:
 */
  __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_long(((PyObject *)__pyx_v_self->__pyx_base._position_hash));
  if (unlikely(!__pyx_t_2.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_phash = __pyx_t_2;
  __pyx_t_2.memview = NULL;
  __pyx_t_2.data = NULL;

  /* "plastid/genomics/roitools.pyx":3377
 *             long [:] phash = self._position_hash
 * 
 *         if self.spanning_segment.c_strand == forward_strand:             # <<<<<<<<<<<<<<
 *             self.cds_genome_start = phash[cds_start]
 *         else:
 */
  __pyx_t_3 = ((__pyx_v_self->__pyx_base.spanning_segment->c_strand == __pyx_e_7plastid_8genomics_8c_common_forward_strand) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3378
 * 
 *         if self.spanning_segment.c_strand == forward_strand:
 *             self.cds_genome_start = phash[cds_start]             # <<<<<<<<<<<<<<
 *         else:
 *             self.cds_genome_end = phash[self.length - cds_start - 1] + 1 # CHECKME
 */
    __pyx_t_4 = __pyx_v_cds_start;
    __pyx_t_5 = -1;
    if (__pyx_t_4 < 0) {
      __pyx_t_4 += __pyx_v_phash.shape[0];
      if (unlikely(__pyx_t_4 < 0)) __pyx_t_5 = 0;
    } else if (unlikely(__pyx_t_4 >= __pyx_v_phash.shape[0])) __pyx_t_5 = 0;
    if (unlikely(__pyx_t_5 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_5);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = __Pyx_PyInt_From_long((*((long *) ( /* dim=0 */ (__pyx_v_phash.data + __pyx_t_4 * __pyx_v_phash.strides[0]) )))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
    __Pyx_DECREF(__pyx_v_self->cds_genome_start);
    __pyx_v_self->cds_genome_start = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":3377
 *             long [:] phash = self._position_hash
 * 
 *         if self.spanning_segment.c_strand == forward_strand:             # <<<<<<<<<<<<<<
 *             self.cds_genome_start = phash[cds_start]
 *         else:
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":3380
 *             self.cds_genome_start = phash[cds_start]
 *         else:
 *             self.cds_genome_end = phash[self.length - cds_start - 1] + 1 # CHECKME             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
  /*else*/ {
    __pyx_t_7 = ((__pyx_v_self->__pyx_base.length - __pyx_v_cds_start) - 1);
    __pyx_t_5 = -1;
    if (__pyx_t_7 < 0) {
      __pyx_t_7 += __pyx_v_phash.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __pyx_t_5 = 0;
    } else if (unlikely(__pyx_t_7 >= __pyx_v_phash.shape[0])) __pyx_t_5 = 0;
    if (unlikely(__pyx_t_5 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_5);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = __Pyx_PyInt_From_long(((*((long *) ( /* dim=0 */ (__pyx_v_phash.data + __pyx_t_7 * __pyx_v_phash.strides[0]) ))) + 1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
    __Pyx_DECREF(__pyx_v_self->cds_genome_end);
    __pyx_v_self->cds_genome_end = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":3382
 *             self.cds_genome_end = phash[self.length - cds_start - 1] + 1 # CHECKME
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef bint _update_from_cds_end(self) except False:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3372
 *         return True
 * 
 *     cdef bint _update_from_cds_start(self) except False:             # <<<<<<<<<<<<<<
 *         cdef:
 *             long cds_start = <long>self.cds_start
 */

  /* function exit code */
  __pyx_L1_error:;
  __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript._update_from_cds_start", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_phash, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3384
 *         return True
 * 
 *     cdef bint _update_from_cds_end(self) except False:             # <<<<<<<<<<<<<<
 *         cdef:
 *             long cds_end = <long>self.cds_end
 */

static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_end(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  long __pyx_v_cds_end;
  __Pyx_memviewslice __pyx_v_phash = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_update_from_cds_end", 0);

  /* "plastid/genomics/roitools.pyx":3386
 *     cdef bint _update_from_cds_end(self) except False:
 *         cdef:
 *             long cds_end = <long>self.cds_end             # <<<<<<<<<<<<<<
 *             long [:] phash = self._position_hash
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_As_long(__pyx_v_self->cds_end); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cds_end = ((long)__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3387
 *         cdef:
 *             long cds_end = <long>self.cds_end
 *             long [:] phash = self._position_hash             # <<<<<<<<<<<<<<
 * 
 *         if self.spanning_segment.c_strand == forward_strand:
 */
  __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_ds_long(((PyObject *)__pyx_v_self->__pyx_base._position_hash));
  if (unlikely(!__pyx_t_2.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_phash = __pyx_t_2;
  __pyx_t_2.memview = NULL;
  __pyx_t_2.data = NULL;

  /* "plastid/genomics/roitools.pyx":3389
 *             long [:] phash = self._position_hash
 * 
 *         if self.spanning_segment.c_strand == forward_strand:             # <<<<<<<<<<<<<<
 *             self.cds_genome_end = phash[cds_end - 1] + 1
 *         else:
 */
  __pyx_t_3 = ((__pyx_v_self->__pyx_base.spanning_segment->c_strand == __pyx_e_7plastid_8genomics_8c_common_forward_strand) != 0);
  if (__pyx_t_3) {

    /* "plastid/genomics/roitools.pyx":3390
 * 
 *         if self.spanning_segment.c_strand == forward_strand:
 *             self.cds_genome_end = phash[cds_end - 1] + 1             # <<<<<<<<<<<<<<
 *         else:
 *             self.cds_genome_start = phash[self.length - cds_end]
 */
    __pyx_t_4 = (__pyx_v_cds_end - 1);
    __pyx_t_5 = -1;
    if (__pyx_t_4 < 0) {
      __pyx_t_4 += __pyx_v_phash.shape[0];
      if (unlikely(__pyx_t_4 < 0)) __pyx_t_5 = 0;
    } else if (unlikely(__pyx_t_4 >= __pyx_v_phash.shape[0])) __pyx_t_5 = 0;
    if (unlikely(__pyx_t_5 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_5);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = __Pyx_PyInt_From_long(((*((long *) ( /* dim=0 */ (__pyx_v_phash.data + __pyx_t_4 * __pyx_v_phash.strides[0]) ))) + 1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_end);
    __Pyx_DECREF(__pyx_v_self->cds_genome_end);
    __pyx_v_self->cds_genome_end = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":3389
 *             long [:] phash = self._position_hash
 * 
 *         if self.spanning_segment.c_strand == forward_strand:             # <<<<<<<<<<<<<<
 *             self.cds_genome_end = phash[cds_end - 1] + 1
 *         else:
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":3392
 *             self.cds_genome_end = phash[cds_end - 1] + 1
 *         else:
 *             self.cds_genome_start = phash[self.length - cds_end]             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
  /*else*/ {
    __pyx_t_7 = (__pyx_v_self->__pyx_base.length - __pyx_v_cds_end);
    __pyx_t_5 = -1;
    if (__pyx_t_7 < 0) {
      __pyx_t_7 += __pyx_v_phash.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __pyx_t_5 = 0;
    } else if (unlikely(__pyx_t_7 >= __pyx_v_phash.shape[0])) __pyx_t_5 = 0;
    if (unlikely(__pyx_t_5 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_5);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = __Pyx_PyInt_From_long((*((long *) ( /* dim=0 */ (__pyx_v_phash.data + __pyx_t_7 * __pyx_v_phash.strides[0]) )))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->cds_genome_start);
    __Pyx_DECREF(__pyx_v_self->cds_genome_start);
    __pyx_v_self->cds_genome_start = __pyx_t_6;
    __pyx_t_6 = 0;
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":3394
 *             self.cds_genome_start = phash[self.length - cds_end]
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef bint _update_from_cds_genome_start(self) except False:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3384
 *         return True
 * 
 *     cdef bint _update_from_cds_end(self) except False:             # <<<<<<<<<<<<<<
 *         cdef:
 *             long cds_end = <long>self.cds_end
 */

  /* function exit code */
  __pyx_L1_error:;
  __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript._update_from_cds_end", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_phash, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3396
 *         return True
 * 
 *     cdef bint _update_from_cds_genome_start(self) except False:             # <<<<<<<<<<<<<<
 *         """Generate `self.cds_start` and `self.cds_end` from `self.cds_genome_start` and `self.cds_genome_end`
 *         AFTER verifying that these values are not None
 */

static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_genome_start(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  long __pyx_v_cds_genome_start;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __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("_update_from_cds_genome_start", 0);

  /* "plastid/genomics/roitools.pyx":3401
 *         """
 *         cdef:
 *             long cds_genome_start = <long>self.cds_genome_start             # <<<<<<<<<<<<<<
 * 
 *         if self.spanning_segment.c_strand == forward_strand:
 */
  __pyx_t_1 = __Pyx_PyInt_As_long(__pyx_v_self->cds_genome_start); if (unlikely((__pyx_t_1 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cds_genome_start = ((long)__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3403
 *             long cds_genome_start = <long>self.cds_genome_start
 * 
 *         if self.spanning_segment.c_strand == forward_strand:             # <<<<<<<<<<<<<<
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_start,True)
 *         else:
 */
  __pyx_t_2 = ((__pyx_v_self->__pyx_base.spanning_segment->c_strand == __pyx_e_7plastid_8genomics_8c_common_forward_strand) != 0);
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3404
 * 
 *         if self.spanning_segment.c_strand == forward_strand:
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_start,True)             # <<<<<<<<<<<<<<
 *         else:
 *             self.cds_end   = 1 + self.c_get_segmentchain_coordinate(cds_genome_start,True)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_cds_genome_start, 1); if (unlikely(__pyx_t_1 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3403
 *             long cds_genome_start = <long>self.cds_genome_start
 * 
 *         if self.spanning_segment.c_strand == forward_strand:             # <<<<<<<<<<<<<<
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_start,True)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":3406
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_start,True)
 *         else:
 *             self.cds_end   = 1 + self.c_get_segmentchain_coordinate(cds_genome_start,True)             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
  /*else*/ {
    __pyx_t_1 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_cds_genome_start, 1); if (unlikely(__pyx_t_1 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __Pyx_PyInt_From_long((1 + __pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->cds_end);
    __Pyx_DECREF(__pyx_v_self->cds_end);
    __pyx_v_self->cds_end = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":3408
 *             self.cds_end   = 1 + self.c_get_segmentchain_coordinate(cds_genome_start,True)
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef bint _update_from_cds_genome_end(self) except False:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3396
 *         return True
 * 
 *     cdef bint _update_from_cds_genome_start(self) except False:             # <<<<<<<<<<<<<<
 *         """Generate `self.cds_start` and `self.cds_end` from `self.cds_genome_start` and `self.cds_genome_end`
 *         AFTER verifying that these values are not None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript._update_from_cds_genome_start", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3410
 *         return True
 * 
 *     cdef bint _update_from_cds_genome_end(self) except False:             # <<<<<<<<<<<<<<
 *         """Generate `self.cds_start` and `self.cds_end` from `self.cds_genome_start` and `self.cds_genome_end`
 *         AFTER verifying that these values are not None
 */

static int __pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_genome_end(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_span = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_strand;
  CYTHON_UNUSED PyObject *__pyx_v_chrom = 0;
  CYTHON_UNUSED long __pyx_v_cds_genome_start;
  long __pyx_v_cds_genome_end;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_t_2;
  long __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  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("_update_from_cds_genome_end", 0);

  /* "plastid/genomics/roitools.pyx":3415
 *         """
 *         cdef:
 *             GenomicSegment span = self.spanning_segment             # <<<<<<<<<<<<<<
 *             Strand strand = span.c_strand
 *             str chrom = span.chrom
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_span = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3416
 *         cdef:
 *             GenomicSegment span = self.spanning_segment
 *             Strand strand = span.c_strand             # <<<<<<<<<<<<<<
 *             str chrom = span.chrom
 *             long cds_genome_start = self.cds_genome_start
 */
  __pyx_t_2 = __pyx_v_span->c_strand;
  __pyx_v_strand = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":3417
 *             GenomicSegment span = self.spanning_segment
 *             Strand strand = span.c_strand
 *             str chrom = span.chrom             # <<<<<<<<<<<<<<
 *             long cds_genome_start = self.cds_genome_start
 *             long cds_genome_end   = self.cds_genome_end
 */
  __pyx_t_1 = __pyx_v_span->chrom;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_chrom = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3418
 *             Strand strand = span.c_strand
 *             str chrom = span.chrom
 *             long cds_genome_start = self.cds_genome_start             # <<<<<<<<<<<<<<
 *             long cds_genome_end   = self.cds_genome_end
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_As_long(__pyx_v_self->cds_genome_start); if (unlikely((__pyx_t_3 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cds_genome_start = __pyx_t_3;

  /* "plastid/genomics/roitools.pyx":3419
 *             str chrom = span.chrom
 *             long cds_genome_start = self.cds_genome_start
 *             long cds_genome_end   = self.cds_genome_end             # <<<<<<<<<<<<<<
 * 
 *         if strand == forward_strand:
 */
  __pyx_t_3 = __Pyx_PyInt_As_long(__pyx_v_self->cds_genome_end); if (unlikely((__pyx_t_3 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cds_genome_end = __pyx_t_3;

  /* "plastid/genomics/roitools.pyx":3421
 *             long cds_genome_end   = self.cds_genome_end
 * 
 *         if strand == forward_strand:             # <<<<<<<<<<<<<<
 *             # this is in a try-catch because if the half-open cds_end coincides
 *             # with the end of an exon, it will not be in the end-inclusive position
 */
  __pyx_t_4 = ((__pyx_v_strand == __pyx_e_7plastid_8genomics_8c_common_forward_strand) != 0);
  if (__pyx_t_4) {

    /* "plastid/genomics/roitools.pyx":3424
 *             # this is in a try-catch because if the half-open cds_end coincides
 *             # with the end of an exon, it will not be in the end-inclusive position
 *             try:             # <<<<<<<<<<<<<<
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)
 *             except KeyError:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      /*try:*/ {

        /* "plastid/genomics/roitools.pyx":3425
 *             # with the end of an exon, it will not be in the end-inclusive position
 *             try:
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)             # <<<<<<<<<<<<<<
 *             except KeyError:
 *                 # minus one, plus one corrections because end-exclusive genome
 */
        __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_v_cds_genome_end, 1); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_v_self->cds_end);
        __Pyx_DECREF(__pyx_v_self->cds_end);
        __pyx_v_self->cds_end = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "plastid/genomics/roitools.pyx":3424
 *             # this is in a try-catch because if the half-open cds_end coincides
 *             # with the end of an exon, it will not be in the end-inclusive position
 *             try:             # <<<<<<<<<<<<<<
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)
 *             except KeyError:
 */
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "plastid/genomics/roitools.pyx":3426
 *             try:
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)
 *             except KeyError:             # <<<<<<<<<<<<<<
 *                 # minus one, plus one corrections because end-exclusive genome
 *                 # position will not be in position hash if it coincides with
 */
      __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
      if (__pyx_t_8) {
        __Pyx_AddTraceback("plastid.genomics.roitools.Transcript._update_from_cds_genome_end", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_9, &__pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3426; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_10);

        /* "plastid/genomics/roitools.pyx":3430
 *                 # position will not be in position hash if it coincides with
 *                 # the end of any exon
 *                 self.cds_end   = 1 + self.c_get_segmentchain_coordinate(cds_genome_end - 1,True)             # <<<<<<<<<<<<<<
 *         else:
 *             # likewise for minus-strand
 */
        __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), (__pyx_v_cds_genome_end - 1), 1); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3430; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __pyx_t_11 = __Pyx_PyInt_From_long((1 + __pyx_t_3)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3430; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __Pyx_GOTREF(__pyx_v_self->cds_end);
        __Pyx_DECREF(__pyx_v_self->cds_end);
        __pyx_v_self->cds_end = __pyx_t_11;
        __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L5_exception_handled;
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "plastid/genomics/roitools.pyx":3424
 *             # this is in a try-catch because if the half-open cds_end coincides
 *             # with the end of an exon, it will not be in the end-inclusive position
 *             try:             # <<<<<<<<<<<<<<
 *                 self.cds_end = self.c_get_segmentchain_coordinate(cds_genome_end,True)
 *             except KeyError:
 */
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      __pyx_L11_try_end:;
    }

    /* "plastid/genomics/roitools.pyx":3421
 *             long cds_genome_end   = self.cds_genome_end
 * 
 *         if strand == forward_strand:             # <<<<<<<<<<<<<<
 *             # this is in a try-catch because if the half-open cds_end coincides
 *             # with the end of an exon, it will not be in the end-inclusive position
 */
    goto __pyx_L3;
  }

  /* "plastid/genomics/roitools.pyx":3436
 *             # have been thoroughly tested by examining BED files exported
 *             # for this purpose
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_end - 1,  True)             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
  /*else*/ {
    __pyx_t_3 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_segmentchain_coordinate(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), (__pyx_v_cds_genome_end - 1), 1); if (unlikely(__pyx_t_3 == -1L)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_t_3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_10);
    __Pyx_GOTREF(__pyx_v_self->cds_start);
    __Pyx_DECREF(__pyx_v_self->cds_start);
    __pyx_v_self->cds_start = __pyx_t_10;
    __pyx_t_10 = 0;
  }
  __pyx_L3:;

  /* "plastid/genomics/roitools.pyx":3438
 *             self.cds_start = self.c_get_segmentchain_coordinate(cds_genome_end - 1,  True)
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def get_name(self):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3410
 *         return True
 * 
 *     cdef bint _update_from_cds_genome_end(self) except False:             # <<<<<<<<<<<<<<
 *         """Generate `self.cds_start` and `self.cds_end` from `self.cds_genome_start` and `self.cds_genome_end`
 *         AFTER verifying that these values are not None
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript._update_from_cds_genome_end", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_span);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3440
 *         return True
 * 
 *     def get_name(self):             # <<<<<<<<<<<<<<
 *         """Return the name of `self`, first searching through
 *         `self.attr` for the keys `transcript_id`, `ID`, `Name`, and `name`.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_15get_name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_14get_name[] = "Transcript.get_name(self)\nReturn the name of `self`, first searching through\n        `self.attr` for the keys `transcript_id`, `ID`, `Name`, and `name`.\n        If no value is found, :meth:`Transcript.__str__` is used.\n        \n        Returns\n        -------\n        str\n            Returns in order of preference, `transcript_id`, `ID`, `Name`,\n            or `name` from `self.attr`. If not found, returns ``str(self)``\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_15get_name(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_name (wrapper)", 0);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_14get_name(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_14get_name(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self) {
  PyObject *__pyx_v_name = 0;
  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("get_name", 0);

  /* "plastid/genomics/roitools.pyx":3452
 *         """
 *         cdef str name
 *         name = self.attr.get("transcript_id",             # <<<<<<<<<<<<<<
 *                self.attr.get("ID",
 *                self.attr.get("Name",
 */
  if (unlikely(__pyx_v_self->__pyx_base.attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":3453
 *         cdef str name
 *         name = self.attr.get("transcript_id",
 *                self.attr.get("ID",             # <<<<<<<<<<<<<<
 *                self.attr.get("Name",
 *                self.attr.get("name",
 */
  if (unlikely(__pyx_v_self->__pyx_base.attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":3454
 *         name = self.attr.get("transcript_id",
 *                self.attr.get("ID",
 *                self.attr.get("Name",             # <<<<<<<<<<<<<<
 *                self.attr.get("name",
 *                              str(self)))))
 */
  if (unlikely(__pyx_v_self->__pyx_base.attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":3455
 *                self.attr.get("ID",
 *                self.attr.get("Name",
 *                self.attr.get("name",             # <<<<<<<<<<<<<<
 *                              str(self)))))
 *         return name
 */
  if (unlikely(__pyx_v_self->__pyx_base.attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "plastid/genomics/roitools.pyx":3456
 *                self.attr.get("Name",
 *                self.attr.get("name",
 *                              str(self)))))             # <<<<<<<<<<<<<<
 *         return name
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3455
 *                self.attr.get("ID",
 *                self.attr.get("Name",
 *                self.attr.get("name",             # <<<<<<<<<<<<<<
 *                              str(self)))))
 *         return name
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->__pyx_base.attr, __pyx_n_s_name_2, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3454
 *         name = self.attr.get("transcript_id",
 *                self.attr.get("ID",
 *                self.attr.get("Name",             # <<<<<<<<<<<<<<
 *                self.attr.get("name",
 *                              str(self)))))
 */
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->__pyx_base.attr, __pyx_n_s_Name, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3453
 *         cdef str name
 *         name = self.attr.get("transcript_id",
 *                self.attr.get("ID",             # <<<<<<<<<<<<<<
 *                self.attr.get("Name",
 *                self.attr.get("name",
 */
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->__pyx_base.attr, __pyx_n_s_ID, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3452
 *         """
 *         cdef str name
 *         name = self.attr.get("transcript_id",             # <<<<<<<<<<<<<<
 *                self.attr.get("ID",
 *                self.attr.get("Name",
 */
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->__pyx_base.attr, __pyx_n_s_transcript_id, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_name = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":3457
 *                self.attr.get("name",
 *                              str(self)))))
 *         return name             # <<<<<<<<<<<<<<
 * 
 *     def get_cds(self,**extra_attr):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_name);
  __pyx_r = __pyx_v_name;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3440
 *         return True
 * 
 *     def get_name(self):             # <<<<<<<<<<<<<<
 *         """Return the name of `self`, first searching through
 *         `self.attr` for the keys `transcript_id`, `ID`, `Name`, and `name`.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.get_name", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3459
 *         return name
 * 
 *     def get_cds(self,**extra_attr):             # <<<<<<<<<<<<<<
 *         """Retrieve |SegmentChain| covering the coding region of `self`, including the stop codon.
 *         If no coding region is present, returns an empty |SegmentChain|.
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_17get_cds(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_16get_cds[] = "Transcript.get_cds(self, **extra_attr)\nRetrieve |SegmentChain| covering the coding region of `self`, including the stop codon.\n        If no coding region is present, returns an empty |SegmentChain|.\n        \n        The following attributes are passed from `self.attr` to the new |SegmentChain|\n        \n            #. transcript_id, taken from :py:meth:`SegmentChain.get_name`\n            #. gene_id, taken from :py:meth:`SegmentChain.get_gene`\n            #. ID, generated as `\"%s_CDS % self.get_name()`\n\n\n        Parameters\n        ----------\n        extra_attr : keyword arguments\n            Values that will be included in the CDS subchain's `attr` dict.\n            These can be used to overwrite values already present.\n        \n        Returns\n        -------\n        |SegmentChain|\n            CDS region of `self` if present, otherwise empty |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_17get_cds(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_extra_attr = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_cds (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("get_cds", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return NULL;}
  if (__pyx_kwds && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "get_cds", 1))) return NULL;
  __pyx_v_extra_attr = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_extra_attr)) return NULL;
  __Pyx_GOTREF(__pyx_v_extra_attr);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_16get_cds(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), __pyx_v_extra_attr);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_extra_attr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_16get_cds(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_extra_attr) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_chain = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_transcript = 0;
  CYTHON_UNUSED PyObject *__pyx_v_old_attr = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  long __pyx_t_5;
  long __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("get_cds", 0);

  /* "plastid/genomics/roitools.pyx":3483
 *         cdef:
 *             SegmentChain chain
 *             Transcript transcript = Transcript()             # <<<<<<<<<<<<<<
 *             dict old_attr = {}
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_transcript = ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3484
 *             SegmentChain chain
 *             Transcript transcript = Transcript()
 *             dict old_attr = {}             # <<<<<<<<<<<<<<
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_old_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3486
 *             dict old_attr = {}
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 *             chain = self.c_get_subchain(self.cds_start,
 *                                         self.cds_end,
 */
  __pyx_t_3 = (__pyx_v_self->cds_genome_start != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_self->cds_genome_end != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3487
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:
 *             chain = self.c_get_subchain(self.cds_start,             # <<<<<<<<<<<<<<
 *                                         self.cds_end,
 *                                         True)
 */
    __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_v_self->cds_start); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3488
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:
 *             chain = self.c_get_subchain(self.cds_start,
 *                                         self.cds_end,             # <<<<<<<<<<<<<<
 *                                         True)
 * 
 */
    __pyx_t_6 = __Pyx_PyInt_As_long(__pyx_v_self->cds_end); if (unlikely((__pyx_t_6 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3487
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:
 *             chain = self.c_get_subchain(self.cds_start,             # <<<<<<<<<<<<<<
 *                                         self.cds_end,
 *                                         True)
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_subchain(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_t_5, __pyx_t_6, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_chain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3491
 *                                         True)
 * 
 *             transcript._set_segments(chain._segments)             # <<<<<<<<<<<<<<
 *             transcript.attr = chain.attr
 *             transcript.attr.update(extra_attr)
 */
    __pyx_t_1 = __pyx_v_chain->_segments;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_transcript->__pyx_base.__pyx_vtab)->__pyx_base._set_segments(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_transcript), ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3492
 * 
 *             transcript._set_segments(chain._segments)
 *             transcript.attr = chain.attr             # <<<<<<<<<<<<<<
 *             transcript.attr.update(extra_attr)
 *             transcript.cds_genome_start = self.cds_genome_start
 */
    __pyx_t_1 = __pyx_v_chain->attr;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_transcript->__pyx_base.attr);
    __Pyx_DECREF(__pyx_v_transcript->__pyx_base.attr);
    __pyx_v_transcript->__pyx_base.attr = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3493
 *             transcript._set_segments(chain._segments)
 *             transcript.attr = chain.attr
 *             transcript.attr.update(extra_attr)             # <<<<<<<<<<<<<<
 *             transcript.cds_genome_start = self.cds_genome_start
 *             transcript.cds_genome_end   = self.cds_genome_end
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_transcript->__pyx_base.attr, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_extra_attr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_INCREF(__pyx_v_extra_attr);
      __Pyx_GIVEREF(__pyx_v_extra_attr);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_extra_attr);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3493; __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_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3494
 *             transcript.attr = chain.attr
 *             transcript.attr.update(extra_attr)
 *             transcript.cds_genome_start = self.cds_genome_start             # <<<<<<<<<<<<<<
 *             transcript.cds_genome_end   = self.cds_genome_end
 *             transcript._update_cds()
 */
    __pyx_t_1 = __pyx_v_self->cds_genome_start;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_transcript->cds_genome_start);
    __Pyx_DECREF(__pyx_v_transcript->cds_genome_start);
    __pyx_v_transcript->cds_genome_start = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3495
 *             transcript.attr.update(extra_attr)
 *             transcript.cds_genome_start = self.cds_genome_start
 *             transcript.cds_genome_end   = self.cds_genome_end             # <<<<<<<<<<<<<<
 *             transcript._update_cds()
 * 
 */
    __pyx_t_1 = __pyx_v_self->cds_genome_end;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_transcript->cds_genome_end);
    __Pyx_DECREF(__pyx_v_transcript->cds_genome_end);
    __pyx_v_transcript->cds_genome_end = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3496
 *             transcript.cds_genome_start = self.cds_genome_start
 *             transcript.cds_genome_end   = self.cds_genome_end
 *             transcript._update_cds()             # <<<<<<<<<<<<<<
 * 
 *         return transcript
 */
    __pyx_t_2 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_transcript->__pyx_base.__pyx_vtab)->_update_cds(__pyx_v_transcript); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3486
 *             dict old_attr = {}
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 *             chain = self.c_get_subchain(self.cds_start,
 *                                         self.cds_end,
 */
  }

  /* "plastid/genomics/roitools.pyx":3498
 *             transcript._update_cds()
 * 
 *         return transcript             # <<<<<<<<<<<<<<
 * 
 *     def get_utr5(self,**extra_attr):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_transcript));
  __pyx_r = ((PyObject *)__pyx_v_transcript);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3459
 *         return name
 * 
 *     def get_cds(self,**extra_attr):             # <<<<<<<<<<<<<<
 *         """Retrieve |SegmentChain| covering the coding region of `self`, including the stop codon.
 *         If no coding region is present, returns an empty |SegmentChain|.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.get_cds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_chain);
  __Pyx_XDECREF((PyObject *)__pyx_v_transcript);
  __Pyx_XDECREF(__pyx_v_old_attr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3500
 *         return transcript
 * 
 *     def get_utr5(self,**extra_attr):             # <<<<<<<<<<<<<<
 *         """Retrieve sub-|SegmentChain| covering 5'UTR of `self`.
 *         If no coding region, returns an empty |SegmentChain|
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_19get_utr5(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_18get_utr5[] = "Transcript.get_utr5(self, **extra_attr)\nRetrieve sub-|SegmentChain| covering 5'UTR of `self`.\n        If no coding region, returns an empty |SegmentChain|\n\n        The following attributes are passed from `self.attr` to the new |SegmentChain|\n        \n            #. transcript_id, taken from :py:meth:`SegmentChain.get_name`\n            #. gene_id, taken from :py:meth:`SegmentChain.get_gene`\n            #. ID, generated as `\"%s_5UTR\" % self.get_name()`\n\n\n        Parameters\n        ----------\n        extra_attr : keyword arguments\n            Values that will be included in the 5'UTR subchain's `attr` dict.\n            These can be used to overwrite values already present.\n\n\n        Returns\n        -------\n        |SegmentChain|\n            5' UTR region of `self` if present, otherwise empty |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_19get_utr5(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_extra_attr = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_utr5 (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("get_utr5", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return NULL;}
  if (__pyx_kwds && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "get_utr5", 1))) return NULL;
  __pyx_v_extra_attr = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_extra_attr)) return NULL;
  __Pyx_GOTREF(__pyx_v_extra_attr);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_18get_utr5(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), __pyx_v_extra_attr);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_extra_attr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_18get_utr5(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_extra_attr) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_my_segmentchain = 0;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  long __pyx_t_5;
  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("get_utr5", 0);

  /* "plastid/genomics/roitools.pyx":3525
 *         cdef:
 *             SegmentChain my_segmentchain
 *             dict attr = {}             # <<<<<<<<<<<<<<
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3527
 *             dict attr = {}
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 * 
 *             my_segmentchain = self.c_get_subchain(0,self.cds_start,True)
 */
  __pyx_t_3 = (__pyx_v_self->cds_genome_start != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_self->cds_genome_end != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3529
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:
 * 
 *             my_segmentchain = self.c_get_subchain(0,self.cds_start,True)             # <<<<<<<<<<<<<<
 *             attr["type"] = "5UTR"
 *             attr["gene_id"] = self.get_gene()
 */
    __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_v_self->cds_start); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_subchain(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), 0, __pyx_t_5, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_my_segmentchain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3530
 * 
 *             my_segmentchain = self.c_get_subchain(0,self.cds_start,True)
 *             attr["type"] = "5UTR"             # <<<<<<<<<<<<<<
 *             attr["gene_id"] = self.get_gene()
 *             attr["transcript_id"] = self.get_gene()
 */
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_type, __pyx_kp_s_5UTR) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3531
 *             my_segmentchain = self.c_get_subchain(0,self.cds_start,True)
 *             attr["type"] = "5UTR"
 *             attr["gene_id"] = self.get_gene()             # <<<<<<<<<<<<<<
 *             attr["transcript_id"] = self.get_gene()
 *             attr["ID"] = "%s_5UTR" % self.get_name()
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_gene); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_gene_id, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3532
 *             attr["type"] = "5UTR"
 *             attr["gene_id"] = self.get_gene()
 *             attr["transcript_id"] = self.get_gene()             # <<<<<<<<<<<<<<
 *             attr["ID"] = "%s_5UTR" % self.get_name()
 *             my_segmentchain.attr = attr
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_gene); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_transcript_id, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3533
 *             attr["gene_id"] = self.get_gene()
 *             attr["transcript_id"] = self.get_gene()
 *             attr["ID"] = "%s_5UTR" % self.get_name()             # <<<<<<<<<<<<<<
 *             my_segmentchain.attr = attr
 *             my_segmentchain.attr.update(extra_attr)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_5UTR, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_ID, __pyx_t_6) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":3534
 *             attr["transcript_id"] = self.get_gene()
 *             attr["ID"] = "%s_5UTR" % self.get_name()
 *             my_segmentchain.attr = attr             # <<<<<<<<<<<<<<
 *             my_segmentchain.attr.update(extra_attr)
 * 
 */
    __Pyx_INCREF(__pyx_v_attr);
    __Pyx_GIVEREF(__pyx_v_attr);
    __Pyx_GOTREF(__pyx_v_my_segmentchain->attr);
    __Pyx_DECREF(__pyx_v_my_segmentchain->attr);
    __pyx_v_my_segmentchain->attr = __pyx_v_attr;

    /* "plastid/genomics/roitools.pyx":3535
 *             attr["ID"] = "%s_5UTR" % self.get_name()
 *             my_segmentchain.attr = attr
 *             my_segmentchain.attr.update(extra_attr)             # <<<<<<<<<<<<<<
 * 
 *             return my_segmentchain
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_my_segmentchain->attr, __pyx_n_s_update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_extra_attr); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_extra_attr);
      __Pyx_GIVEREF(__pyx_v_extra_attr);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_extra_attr);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":3537
 *             my_segmentchain.attr.update(extra_attr)
 * 
 *             return my_segmentchain             # <<<<<<<<<<<<<<
 *         else:
 *             return SegmentChain()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_my_segmentchain));
    __pyx_r = ((PyObject *)__pyx_v_my_segmentchain);
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":3527
 *             dict attr = {}
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 * 
 *             my_segmentchain = self.c_get_subchain(0,self.cds_start,True)
 */
  }

  /* "plastid/genomics/roitools.pyx":3539
 *             return my_segmentchain
 *         else:
 *             return SegmentChain()             # <<<<<<<<<<<<<<
 * 
 *     def get_utr3(self,**extra_attr):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":3500
 *         return transcript
 * 
 *     def get_utr5(self,**extra_attr):             # <<<<<<<<<<<<<<
 *         """Retrieve sub-|SegmentChain| covering 5'UTR of `self`.
 *         If no coding region, returns an empty |SegmentChain|
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.get_utr5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_my_segmentchain);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3541
 *             return SegmentChain()
 * 
 *     def get_utr3(self,**extra_attr):             # <<<<<<<<<<<<<<
 *         """Retrieve sub-|SegmentChain| covering 3'UTR of `self`, excluding
 *         the stop codon. If no coding region, returns an empty |SegmentChain|
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_21get_utr3(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_20get_utr3[] = "Transcript.get_utr3(self, **extra_attr)\nRetrieve sub-|SegmentChain| covering 3'UTR of `self`, excluding\n        the stop codon. If no coding region, returns an empty |SegmentChain|\n        \n        The following attributes are passed from ``self.attr`` to the new |SegmentChain|\n        \n            #. transcript_id, taken from :py:meth:`SegmentChain.get_name`\n            #. gene_id, taken from :py:meth:`SegmentChain.get_gene`\n            #. ID, generated as `\"%s_3UTR\" % self.get_name()`\n\n\n        Parameters\n        ----------\n        extra_attr : keyword arguments\n            Values that will be included in the 3' UTR subchain's `attr` dict.\n            These can be used to overwrite values already present.\n\n\n        Returns\n        -------\n        |SegmentChain|\n            3' UTR region of `self` if present, otherwise empty |SegmentChain|\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_21get_utr3(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_extra_attr = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_utr3 (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("get_utr3", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return NULL;}
  if (__pyx_kwds && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "get_utr3", 1))) return NULL;
  __pyx_v_extra_attr = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New(); if (unlikely(!__pyx_v_extra_attr)) return NULL;
  __Pyx_GOTREF(__pyx_v_extra_attr);
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_20get_utr3(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), __pyx_v_extra_attr);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_extra_attr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_20get_utr3(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_extra_attr) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_my_segmentchain = 0;
  PyObject *__pyx_v_attr = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  long __pyx_t_5;
  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("get_utr3", 0);

  /* "plastid/genomics/roitools.pyx":3566
 *         cdef:
 *             SegmentChain my_segmentchain
 *             dict attr = {}             # <<<<<<<<<<<<<<
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3568
 *             dict attr = {}
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 * 
 *             my_segmentchain = self.c_get_subchain(self.cds_end,self.length,True)
 */
  __pyx_t_3 = (__pyx_v_self->cds_genome_start != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_self->cds_genome_end != Py_None);
  __pyx_t_3 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "plastid/genomics/roitools.pyx":3570
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:
 * 
 *             my_segmentchain = self.c_get_subchain(self.cds_end,self.length,True)             # <<<<<<<<<<<<<<
 *             attr["type"] = "3UTR"
 *             attr["gene_id"] = self.get_gene()
 */
    __pyx_t_5 = __Pyx_PyInt_As_long(__pyx_v_self->cds_end); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.c_get_subchain(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_self), __pyx_t_5, __pyx_v_self->__pyx_base.length, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_my_segmentchain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3571
 * 
 *             my_segmentchain = self.c_get_subchain(self.cds_end,self.length,True)
 *             attr["type"] = "3UTR"             # <<<<<<<<<<<<<<
 *             attr["gene_id"] = self.get_gene()
 *             attr["transcript_id"] = self.get_gene()
 */
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_type, __pyx_kp_s_3UTR) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3572
 *             my_segmentchain = self.c_get_subchain(self.cds_end,self.length,True)
 *             attr["type"] = "3UTR"
 *             attr["gene_id"] = self.get_gene()             # <<<<<<<<<<<<<<
 *             attr["transcript_id"] = self.get_gene()
 *             attr["ID"] = "%s_3UTR" % self.get_name()
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_gene); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_gene_id, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3573
 *             attr["type"] = "3UTR"
 *             attr["gene_id"] = self.get_gene()
 *             attr["transcript_id"] = self.get_gene()             # <<<<<<<<<<<<<<
 *             attr["ID"] = "%s_3UTR" % self.get_name()
 *             my_segmentchain.attr.update(attr)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_gene); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_transcript_id, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3574
 *             attr["gene_id"] = self.get_gene()
 *             attr["transcript_id"] = self.get_gene()
 *             attr["ID"] = "%s_3UTR" % self.get_name()             # <<<<<<<<<<<<<<
 *             my_segmentchain.attr.update(attr)
 *             my_segmentchain.attr.update(extra_attr)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_s_3UTR, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_ID, __pyx_t_6) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":3575
 *             attr["transcript_id"] = self.get_gene()
 *             attr["ID"] = "%s_3UTR" % self.get_name()
 *             my_segmentchain.attr.update(attr)             # <<<<<<<<<<<<<<
 *             my_segmentchain.attr.update(extra_attr)
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_my_segmentchain->attr, __pyx_n_s_update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_attr);
      __Pyx_GIVEREF(__pyx_v_attr);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_attr);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":3576
 *             attr["ID"] = "%s_3UTR" % self.get_name()
 *             my_segmentchain.attr.update(attr)
 *             my_segmentchain.attr.update(extra_attr)             # <<<<<<<<<<<<<<
 * 
 *             return my_segmentchain
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_my_segmentchain->attr, __pyx_n_s_update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_extra_attr); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_INCREF(__pyx_v_extra_attr);
      __Pyx_GIVEREF(__pyx_v_extra_attr);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_extra_attr);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "plastid/genomics/roitools.pyx":3578
 *             my_segmentchain.attr.update(extra_attr)
 * 
 *             return my_segmentchain             # <<<<<<<<<<<<<<
 *         else:
 *             return SegmentChain()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_my_segmentchain));
    __pyx_r = ((PyObject *)__pyx_v_my_segmentchain);
    goto __pyx_L0;

    /* "plastid/genomics/roitools.pyx":3568
 *             dict attr = {}
 * 
 *         if self.cds_genome_start is not None and self.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 * 
 *             my_segmentchain = self.c_get_subchain(self.cds_end,self.length,True)
 */
  }

  /* "plastid/genomics/roitools.pyx":3580
 *             return my_segmentchain
 *         else:
 *             return SegmentChain()             # <<<<<<<<<<<<<<
 * 
 *     def as_gtf(self, str feature_type="exon", bint escape=True, list excludes=[]):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }

  /* "plastid/genomics/roitools.pyx":3541
 *             return SegmentChain()
 * 
 *     def get_utr3(self,**extra_attr):             # <<<<<<<<<<<<<<
 *         """Retrieve sub-|SegmentChain| covering 3'UTR of `self`, excluding
 *         the stop codon. If no coding region, returns an empty |SegmentChain|
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.get_utr3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_my_segmentchain);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3582
 *             return SegmentChain()
 * 
 *     def as_gtf(self, str feature_type="exon", bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format `self` as a `GTF2`_ block. |GenomicSegments| are formatted
 *         as `GTF2`_ `'exon'` features. Coding regions, if peresent, are formatted
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_23as_gtf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_22as_gtf[] = "Transcript.as_gtf(self, str feature_type='exon', bool escape=True, list excludes=[])\nFormat `self` as a `GTF2`_ block. |GenomicSegments| are formatted\n        as `GTF2`_ `'exon'` features. Coding regions, if peresent, are formatted\n        as `GTF2`_ `'CDS'` features. Stop codons are excluded in the `'CDS'` features,\n        per the `GTF2`_ specification, and exported separately.\n\n        All attributes from `self.attr` are propagated to the exon and CDS\n        features that are generated.\n\n         \n        Parameters\n        ----------\n        feature_type : str\n            If not None, overrides the `'type'` attribute of `self.attr`\n        \n        escape : bool, optional\n            URL escape tokens in column 9 of `GTF`_ output (Default: `True`)\n        \n        \n        Returns\n        -------\n        str\n            Block of GTF2-formatted text\n\n\n        Notes\n        -----\n        `gene_id` and `transcript_id` are required\n            The `GTF2 specification <http://mblab.wustl.edu/GTF22.html>`_ requires\n            that attributes `gene_id` and `transcript_id` be defined. If these\n            are not present in `self.attr`, their values will be guessed \n            following the rules in :py:meth:`SegmentChain.get_gene` and \n            :py:meth:`SegmentChain.get_name`, respectively.\n        \n        Beware of attribute loss\n            To save memory, only the attributes shared by all of the individual\n            sub-features (e.g. exons) that were used to assemble this |Transcript|\n            have been stored in `self.attr`. This means that upon re-export to `GTF2`_,\n            these sub-features will be lacking any attributes that were specific\n            to them individually. Formally, this is compliant with the \n            `GTF2 specification <http://mblab.wustl.edu/GTF22.html>`_, which states\n            explicitly that only the attributes `gene_id` and `transcript_id`\n            are supported.\n      ""      \n        Columns of `GTF2`_ are as follows\n            ======== =========\n            Column   Contains\n            ======== =========\n                1     Contig or chromosome \n                2     Source of annotation \n                3     Type of feature (\"exon\", \"CDS\", \"start_codon\", \"stop_codon\") \n                4     Start (1-indexed)  \n                5     End (fully-closed)\n                6     Score  \n                7     Strand  \n                8     Frame. Number of bases within feature before first in-frame codon (if coding) \n                9     Attributes. \"gene_id\" and \"transcript_id\" are required                        \n            ======== =========\n        \n        For more info\n            - `GTF2 file format specification <http://mblab.wustl.edu/GTF22.html>`_\n            - `UCSC file format FAQ <http://genome.ucsc.edu/FAQ/FAQformat.html>`_        \n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_23as_gtf(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_feature_type = 0;
  int __pyx_v_escape;
  PyObject *__pyx_v_excludes = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_gtf (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_feature_type,&__pyx_n_s_escape,&__pyx_n_s_excludes,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject*)__pyx_n_s_exon);
    values[2] = __pyx_k__46;
    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_feature_type);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_escape);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_excludes);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "as_gtf") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3582; __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_feature_type = ((PyObject*)values[0]);
    if (values[1]) {
      __pyx_v_escape = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_escape == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_escape = ((int)1);
    }
    __pyx_v_excludes = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("as_gtf", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3582; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.as_gtf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_feature_type), (&PyString_Type), 1, "feature_type", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_excludes), (&PyList_Type), 1, "excludes", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_22as_gtf(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), __pyx_v_feature_type, __pyx_v_escape, __pyx_v_excludes);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_22as_gtf(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_feature_type, int __pyx_v_escape, PyObject *__pyx_v_excludes) {
  PyObject *__pyx_v_stmp = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_cds_chain_temp = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_start_codon_chain = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_stop_codon_chain = 0;
  PyObject *__pyx_v_child_chain_attr = 0;
  PyObject *__pyx_v_cds_positions = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *__pyx_v_span = 0;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_v_my_strand;
  PyObject *__pyx_v_my_chrom = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_cds_chain = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  enum __pyx_t_7plastid_8genomics_8c_common_Strand __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  int __pyx_t_7;
  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("as_gtf", 0);

  /* "plastid/genomics/roitools.pyx":3650
 *             dict child_chain_attr
 *             list cds_positions
 *             GenomicSegment span = self.spanning_segment             # <<<<<<<<<<<<<<
 *             Strand my_strand = span.c_strand
 *             my_chrom = span.chrom
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.spanning_segment);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_span = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3651
 *             list cds_positions
 *             GenomicSegment span = self.spanning_segment
 *             Strand my_strand = span.c_strand             # <<<<<<<<<<<<<<
 *             my_chrom = span.chrom
 * 
 */
  __pyx_t_2 = __pyx_v_span->c_strand;
  __pyx_v_my_strand = __pyx_t_2;

  /* "plastid/genomics/roitools.pyx":3652
 *             GenomicSegment span = self.spanning_segment
 *             Strand my_strand = span.c_strand
 *             my_chrom = span.chrom             # <<<<<<<<<<<<<<
 * 
 *         stmp  = SegmentChain.as_gtf(self,feature_type=feature_type,escape=escape,excludes=[])
 */
  __pyx_t_1 = __pyx_v_span->chrom;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_my_chrom = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3654
 *             my_chrom = span.chrom
 * 
 *         stmp  = SegmentChain.as_gtf(self,feature_type=feature_type,escape=escape,excludes=[])             # <<<<<<<<<<<<<<
 *         cds_chain_temp = self.get_cds()
 *         if len(cds_chain_temp) > 0:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_n_s_as_gtf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __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 = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_feature_type, __pyx_v_feature_type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_escape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_escape, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_excludes, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_stmp = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "plastid/genomics/roitools.pyx":3655
 * 
 *         stmp  = SegmentChain.as_gtf(self,feature_type=feature_type,escape=escape,excludes=[])
 *         cds_chain_temp = self.get_cds()             # <<<<<<<<<<<<<<
 *         if len(cds_chain_temp) > 0:
 *             child_chain_attr  = copy.deepcopy(self.attr)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_cds); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cds_chain_temp = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "plastid/genomics/roitools.pyx":3656
 *         stmp  = SegmentChain.as_gtf(self,feature_type=feature_type,escape=escape,excludes=[])
 *         cds_chain_temp = self.get_cds()
 *         if len(cds_chain_temp) > 0:             # <<<<<<<<<<<<<<
 *             child_chain_attr  = copy.deepcopy(self.attr)
 *             child_chain_attr.pop("type")
 */
  __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_cds_chain_temp)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((__pyx_t_6 > 0) != 0);
  if (__pyx_t_7) {

    /* "plastid/genomics/roitools.pyx":3657
 *         cds_chain_temp = self.get_cds()
 *         if len(cds_chain_temp) > 0:
 *             child_chain_attr  = copy.deepcopy(self.attr)             # <<<<<<<<<<<<<<
 *             child_chain_attr.pop("type")
 *             cds_positions = list(cds_chain_temp.get_position_list())
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->__pyx_base.attr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_self->__pyx_base.attr);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.attr);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_self->__pyx_base.attr);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(PyDict_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_child_chain_attr = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":3658
 *         if len(cds_chain_temp) > 0:
 *             child_chain_attr  = copy.deepcopy(self.attr)
 *             child_chain_attr.pop("type")             # <<<<<<<<<<<<<<
 *             cds_positions = list(cds_chain_temp.get_position_list())
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_child_chain_attr, __pyx_n_s_pop); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3659
 *             child_chain_attr  = copy.deepcopy(self.attr)
 *             child_chain_attr.pop("type")
 *             cds_positions = list(cds_chain_temp.get_position_list())             # <<<<<<<<<<<<<<
 * 
 *             # remove stop codons from CDS, per GTF2 spec
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cds_chain_temp), __pyx_n_s_get_position_list); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_cds_positions = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":3662
 * 
 *             # remove stop codons from CDS, per GTF2 spec
 *             if my_strand == forward_strand:             # <<<<<<<<<<<<<<
 *                 cds_positions = cds_positions[:-3]
 *             else:
 */
    __pyx_t_7 = ((__pyx_v_my_strand == __pyx_e_7plastid_8genomics_8c_common_forward_strand) != 0);
    if (__pyx_t_7) {

      /* "plastid/genomics/roitools.pyx":3663
 *             # remove stop codons from CDS, per GTF2 spec
 *             if my_strand == forward_strand:
 *                 cds_positions = cds_positions[:-3]             # <<<<<<<<<<<<<<
 *             else:
 *                 cds_positions = cds_positions[3:]
 */
      __pyx_t_5 = __Pyx_PyList_GetSlice(__pyx_v_cds_positions, 0, -3L); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF_SET(__pyx_v_cds_positions, ((PyObject*)__pyx_t_5));
      __pyx_t_5 = 0;

      /* "plastid/genomics/roitools.pyx":3662
 * 
 *             # remove stop codons from CDS, per GTF2 spec
 *             if my_strand == forward_strand:             # <<<<<<<<<<<<<<
 *                 cds_positions = cds_positions[:-3]
 *             else:
 */
      goto __pyx_L4;
    }

    /* "plastid/genomics/roitools.pyx":3665
 *                 cds_positions = cds_positions[:-3]
 *             else:
 *                 cds_positions = cds_positions[3:]             # <<<<<<<<<<<<<<
 *             cds_chain = SegmentChain(*positionlist_to_segments(my_chrom,
 *                                                                strand_to_str(my_strand),
 */
    /*else*/ {
      __pyx_t_5 = __Pyx_PyList_GetSlice(__pyx_v_cds_positions, 3, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF_SET(__pyx_v_cds_positions, ((PyObject*)__pyx_t_5));
      __pyx_t_5 = 0;
    }
    __pyx_L4:;

    /* "plastid/genomics/roitools.pyx":3666
 *             else:
 *                 cds_positions = cds_positions[3:]
 *             cds_chain = SegmentChain(*positionlist_to_segments(my_chrom,             # <<<<<<<<<<<<<<
 *                                                                strand_to_str(my_strand),
 *                                                                cds_positions),
 */
    if (!(likely(PyString_CheckExact(__pyx_v_my_chrom))||((__pyx_v_my_chrom) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_my_chrom)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3667
 *                 cds_positions = cds_positions[3:]
 *             cds_chain = SegmentChain(*positionlist_to_segments(my_chrom,
 *                                                                strand_to_str(my_strand),             # <<<<<<<<<<<<<<
 *                                                                cds_positions),
 *                                    type="CDS",**child_chain_attr)
 */
    __pyx_t_5 = __pyx_f_7plastid_8genomics_8roitools_strand_to_str(__pyx_v_my_strand); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);

    /* "plastid/genomics/roitools.pyx":3666
 *             else:
 *                 cds_positions = cds_positions[3:]
 *             cds_chain = SegmentChain(*positionlist_to_segments(my_chrom,             # <<<<<<<<<<<<<<
 *                                                                strand_to_str(my_strand),
 *                                                                cds_positions),
 */
    __pyx_t_3 = __pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments(((PyObject*)__pyx_v_my_chrom), ((PyObject*)__pyx_t_5), __pyx_v_cds_positions, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3669
 *                                                                strand_to_str(my_strand),
 *                                                                cds_positions),
 *                                    type="CDS",**child_chain_attr)             # <<<<<<<<<<<<<<
 *             stmp += cds_chain.as_gtf(feature_type="CDS",escape=escape,excludes=excludes)
 * 
 */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_type, __pyx_n_s_CDS) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __pyx_t_1;
    __pyx_t_1 = 0;
    if (unlikely(__pyx_v_child_chain_attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (__Pyx_MergeKeywords(__pyx_t_3, __pyx_v_child_chain_attr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3666
 *             else:
 *                 cds_positions = cds_positions[3:]
 *             cds_chain = SegmentChain(*positionlist_to_segments(my_chrom,             # <<<<<<<<<<<<<<
 *                                                                strand_to_str(my_strand),
 *                                                                cds_positions),
 */
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_cds_chain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3670
 *                                                                cds_positions),
 *                                    type="CDS",**child_chain_attr)
 *             stmp += cds_chain.as_gtf(feature_type="CDS",escape=escape,excludes=excludes)             # <<<<<<<<<<<<<<
 * 
 *             start_codon_chain = cds_chain_temp.get_subchain(0, 3)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cds_chain), __pyx_n_s_as_gtf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_feature_type, __pyx_n_s_CDS) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_escape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_escape, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_excludes, __pyx_v_excludes) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_stmp, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF_SET(__pyx_v_stmp, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3672
 *             stmp += cds_chain.as_gtf(feature_type="CDS",escape=escape,excludes=excludes)
 * 
 *             start_codon_chain = cds_chain_temp.get_subchain(0, 3)             # <<<<<<<<<<<<<<
 *             start_codon_chain.attr.update(child_chain_attr)
 *             stmp += start_codon_chain.as_gtf(feature_type="start_codon",escape=escape,excludes=excludes)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cds_chain_temp), __pyx_n_s_get_subchain); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_start_codon_chain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":3673
 * 
 *             start_codon_chain = cds_chain_temp.get_subchain(0, 3)
 *             start_codon_chain.attr.update(child_chain_attr)             # <<<<<<<<<<<<<<
 *             stmp += start_codon_chain.as_gtf(feature_type="start_codon",escape=escape,excludes=excludes)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_start_codon_chain->attr, __pyx_n_s_update); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_child_chain_attr); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_INCREF(__pyx_v_child_chain_attr);
      __Pyx_GIVEREF(__pyx_v_child_chain_attr);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_child_chain_attr);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "plastid/genomics/roitools.pyx":3674
 *             start_codon_chain = cds_chain_temp.get_subchain(0, 3)
 *             start_codon_chain.attr.update(child_chain_attr)
 *             stmp += start_codon_chain.as_gtf(feature_type="start_codon",escape=escape,excludes=excludes)             # <<<<<<<<<<<<<<
 * 
 *             stop_codon_chain = cds_chain_temp.get_subchain(cds_chain_temp.get_length()-3, cds_chain_temp.get_length())
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_start_codon_chain), __pyx_n_s_as_gtf); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_feature_type, __pyx_n_s_start_codon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_escape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_escape, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_excludes, __pyx_v_excludes) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_stmp, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF_SET(__pyx_v_stmp, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3676
 *             stmp += start_codon_chain.as_gtf(feature_type="start_codon",escape=escape,excludes=excludes)
 * 
 *             stop_codon_chain = cds_chain_temp.get_subchain(cds_chain_temp.get_length()-3, cds_chain_temp.get_length())             # <<<<<<<<<<<<<<
 *             stop_codon_chain.attr.update(child_chain_attr)
 *             stmp += stop_codon_chain.as_gtf(feature_type="stop_codon",escape=escape,excludes=excludes)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cds_chain_temp), __pyx_n_s_get_subchain); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cds_chain_temp), __pyx_n_s_get_length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_8) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_5, __pyx_int_3, 3, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cds_chain_temp), __pyx_n_s_get_length); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_9 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_stop_codon_chain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3677
 * 
 *             stop_codon_chain = cds_chain_temp.get_subchain(cds_chain_temp.get_length()-3, cds_chain_temp.get_length())
 *             stop_codon_chain.attr.update(child_chain_attr)             # <<<<<<<<<<<<<<
 *             stmp += stop_codon_chain.as_gtf(feature_type="stop_codon",escape=escape,excludes=excludes)
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_stop_codon_chain->attr, __pyx_n_s_update); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_child_chain_attr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_INCREF(__pyx_v_child_chain_attr);
      __Pyx_GIVEREF(__pyx_v_child_chain_attr);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_child_chain_attr);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3678
 *             stop_codon_chain = cds_chain_temp.get_subchain(cds_chain_temp.get_length()-3, cds_chain_temp.get_length())
 *             stop_codon_chain.attr.update(child_chain_attr)
 *             stmp += stop_codon_chain.as_gtf(feature_type="stop_codon",escape=escape,excludes=excludes)             # <<<<<<<<<<<<<<
 * 
 *         return stmp
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_stop_codon_chain), __pyx_n_s_as_gtf); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_feature_type, __pyx_n_s_stop_codon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_escape); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_escape, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_excludes, __pyx_v_excludes) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_stmp, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF_SET(__pyx_v_stmp, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "plastid/genomics/roitools.pyx":3656
 *         stmp  = SegmentChain.as_gtf(self,feature_type=feature_type,escape=escape,excludes=[])
 *         cds_chain_temp = self.get_cds()
 *         if len(cds_chain_temp) > 0:             # <<<<<<<<<<<<<<
 *             child_chain_attr  = copy.deepcopy(self.attr)
 *             child_chain_attr.pop("type")
 */
  }

  /* "plastid/genomics/roitools.pyx":3680
 *             stmp += stop_codon_chain.as_gtf(feature_type="stop_codon",escape=escape,excludes=excludes)
 * 
 *         return stmp             # <<<<<<<<<<<<<<
 * 
 *     def as_gff3(self, bint escape=True, list excludes=[], str rna_type="mRNA"):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_stmp);
  __pyx_r = __pyx_v_stmp;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3582
 *             return SegmentChain()
 * 
 *     def as_gtf(self, str feature_type="exon", bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format `self` as a `GTF2`_ block. |GenomicSegments| are formatted
 *         as `GTF2`_ `'exon'` features. Coding regions, if peresent, are formatted
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.as_gtf", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_stmp);
  __Pyx_XDECREF((PyObject *)__pyx_v_cds_chain_temp);
  __Pyx_XDECREF((PyObject *)__pyx_v_start_codon_chain);
  __Pyx_XDECREF((PyObject *)__pyx_v_stop_codon_chain);
  __Pyx_XDECREF(__pyx_v_child_chain_attr);
  __Pyx_XDECREF(__pyx_v_cds_positions);
  __Pyx_XDECREF((PyObject *)__pyx_v_span);
  __Pyx_XDECREF(__pyx_v_my_chrom);
  __Pyx_XDECREF((PyObject *)__pyx_v_cds_chain);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3682
 *         return stmp
 * 
 *     def as_gff3(self, bint escape=True, list excludes=[], str rna_type="mRNA"):             # <<<<<<<<<<<<<<
 *         """Format a |Transcript| as a block of `GFF3`_ output, following
 *         the schema set out in the `Sequence Ontology (SO) v2.53 <http://www.sequenceontology.org/browser/>`_
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_25as_gff3(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_24as_gff3[] = "Transcript.as_gff3(self, bool escape=True, list excludes=[], str rna_type='mRNA')\nFormat a |Transcript| as a block of `GFF3`_ output, following\n        the schema set out in the `Sequence Ontology (SO) v2.53 <http://www.sequenceontology.org/browser/>`_\n        \n        The |Transcript| will be formatted according to the following rules:\n        \n          1. A feature of type `rna_type` will be created, with `Parent` attribute\n             set to the value of ``self.get_gene()``, and `ID` attribute\n             set to ``self.get_name()``\n        \n          2. For each |GenomicSegment| in `self`, a child feature of type\n             `exon` will be created. The `Parent` attribute of these features\n             will be set to the value of ``self.get_name()``. These will\n             have unique IDs generated from ``self.get_name()``.\n\n          3. If `self` is coding (i.e. has none-`None` value for\n             `self.cds_genome_start` and `self.cds_genome_end`), child features\n             of type `'five_prime_UTR'`, `'CDS'`, and `'three_prime_UTR'` will be created,\n             with `Parent` attributes set to ``self.get_name()``. These will\n             have unique IDs generated from ``self.get_name()``.\n        \n        \n        Parameters\n        ----------\n        escape : bool, optional\n            Escape tokens in column 9 of `GFF3`_ output (Default: `True`)\n        \n        excludes : list, optional\n            List of attribute key names to exclude from column 9\n            (Default: `[]`)\n        \n        rna_type : str, optional\n            Feature type to export RNA as (e.g. `'tRNA'`, `'noncoding_RNA'`,\n            et c. Default: `'mRNA'`)\n\n        \n        Returns\n        -------\n        str\n            Multiline block of `GFF3`_-formatted text\n\n\n        Notes\n        -----\n        Beware of attribute loss\n            This |Transcript| was assembled from multiple individual component\n            features (e.g. s""ingle exons), which may or may not have had their own\n            unique attributes in their original annotation. To reduce overhead, \n            these individual attributes (if they were present) have not been\n            (entirely) stored, and consequently will not (all) be exported.\n            If this poses problems, consider instead importing, modifying, and\n            exporting the component features\n\n        GFF3 schemas vary\n            Different GFF3s have different schemas (parent-child relationships\n            between features). Here we adopt the commonly-used schema set by\n            `Sequence Ontology (SO) v2.53 <http://www.sequenceontology.org/browser/>`_,\n            which may or may not match your schema.\n\n        Columns of `GFF3`_ are as follows\n            ======== =========\n            Column   Contains\n            ======== =========\n                1     Contig or chromosome \n                2     Source of annotation \n                3     Type of feature (\"exon\", \"CDS\", \"start_codon\", \"stop_codon\") \n                4     Start (1-indexed)  \n                5     End (fully-closed)\n                6     Score  \n                7     Strand  \n                8     Frame. Number of bases within feature before first in-frame codon (if coding) \n                9     Attributes                       \n            ======== =========\n\n        For futher information, see\n            - `GFF3 file format specification <http://www.sequenceontology.org/gff3.shtml>`_\n            - `Sequence Ontology (SO) v2.53 <http://www.sequenceontology.org/browser/>`\n            - `SO releases <http://sourceforge.net/projects/song/files/SO_Feature_Annotation/>`_\n            - `UCSC file format FAQ <http://genome.ucsc.edu/FAQ/FAQformat.html>`_\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_25as_gff3(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_escape;
  PyObject *__pyx_v_excludes = 0;
  PyObject *__pyx_v_rna_type = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_gff3 (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_escape,&__pyx_n_s_excludes,&__pyx_n_s_rna_type,0};
    PyObject* values[3] = {0,0,0};
    values[1] = __pyx_k__49;
    values[2] = ((PyObject*)__pyx_n_s_mRNA);
    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_escape);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_excludes);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_rna_type);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "as_gff3") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3682; __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;
      }
    }
    if (values[0]) {
      __pyx_v_escape = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_escape == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3682; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_escape = ((int)1);
    }
    __pyx_v_excludes = ((PyObject*)values[1]);
    __pyx_v_rna_type = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("as_gff3", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3682; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.as_gff3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_excludes), (&PyList_Type), 1, "excludes", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rna_type), (&PyString_Type), 1, "rna_type", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_24as_gff3(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), __pyx_v_escape, __pyx_v_excludes, __pyx_v_rna_type);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_24as_gff3(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, int __pyx_v_escape, PyObject *__pyx_v_excludes, PyObject *__pyx_v_rna_type) {
  PyObject *__pyx_v_gene_id = 0;
  PyObject *__pyx_v_transcript_id = 0;
  PyObject *__pyx_v_ftype = 0;
  PyObject *__pyx_v_my_id = 0;
  PyObject *__pyx_v_ltmp = 0;
  PyObject *__pyx_v_parts = 0;
  PyObject *__pyx_v_child_attr = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_feature = 0;
  int __pyx_v_n;
  PyObject *__pyx_v_keys_to_pop = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_seg = 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;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  Py_ssize_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("as_gff3", 0);

  /* "plastid/genomics/roitools.pyx":3763
 *         """
 *         cdef:
 *             str gene_id       = self.get_gene()             # <<<<<<<<<<<<<<
 *             str transcript_id = self.get_name()
 *             str ftype, my_id
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_gene); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_gene_id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3764
 *         cdef:
 *             str gene_id       = self.get_gene()
 *             str transcript_id = self.get_name()             # <<<<<<<<<<<<<<
 *             str ftype, my_id
 *             list ltmp = []
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_transcript_id = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3766
 *             str transcript_id = self.get_name()
 *             str ftype, my_id
 *             list ltmp = []             # <<<<<<<<<<<<<<
 *             list parts = []
 *             dict child_attr = copy.deepcopy(self.attr)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ltmp = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3767
 *             str ftype, my_id
 *             list ltmp = []
 *             list parts = []             # <<<<<<<<<<<<<<
 *             dict child_attr = copy.deepcopy(self.attr)
 *             SegmentChain feature
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_parts = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3768
 *             list ltmp = []
 *             list parts = []
 *             dict child_attr = copy.deepcopy(self.attr)             # <<<<<<<<<<<<<<
 *             SegmentChain feature
 *             GenomicSegment iv
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->__pyx_base.attr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_self->__pyx_base.attr);
    __Pyx_GIVEREF(__pyx_v_self->__pyx_base.attr);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self->__pyx_base.attr);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_child_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3773
 *             int n
 * 
 *         keys_to_pop = ("ID",)             # <<<<<<<<<<<<<<
 *         for k in keys_to_pop:
 *             if k in child_attr:
 */
  __Pyx_INCREF(__pyx_tuple__50);
  __pyx_v_keys_to_pop = __pyx_tuple__50;

  /* "plastid/genomics/roitools.pyx":3774
 * 
 *         keys_to_pop = ("ID",)
 *         for k in keys_to_pop:             # <<<<<<<<<<<<<<
 *             if k in child_attr:
 *                 child_attr.pop(k)
 */
  __pyx_t_1 = __pyx_v_keys_to_pop; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
  for (;;) {
    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 = 3774; __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 = 3774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3775
 *         keys_to_pop = ("ID",)
 *         for k in keys_to_pop:
 *             if k in child_attr:             # <<<<<<<<<<<<<<
 *                 child_attr.pop(k)
 * 
 */
    if (unlikely(__pyx_v_child_attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = (__Pyx_PyDict_ContainsTF(__pyx_v_k, __pyx_v_child_attr, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (__pyx_t_7) {

      /* "plastid/genomics/roitools.pyx":3776
 *         for k in keys_to_pop:
 *             if k in child_attr:
 *                 child_attr.pop(k)             # <<<<<<<<<<<<<<
 * 
 *         # mRNA feature
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_child_attr, __pyx_n_s_pop); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_INCREF(__pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_k);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "plastid/genomics/roitools.pyx":3775
 *         keys_to_pop = ("ID",)
 *         for k in keys_to_pop:
 *             if k in child_attr:             # <<<<<<<<<<<<<<
 *                 child_attr.pop(k)
 * 
 */
    }

    /* "plastid/genomics/roitools.pyx":3774
 * 
 *         keys_to_pop = ("ID",)
 *         for k in keys_to_pop:             # <<<<<<<<<<<<<<
 *             if k in child_attr:
 *                 child_attr.pop(k)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3779
 * 
 *         # mRNA feature
 *         feature = SegmentChain(self.spanning_segment,ID=transcript_id,Parent=gene_id,type=rna_type)             # <<<<<<<<<<<<<<
 *         ltmp.append(feature.as_gff3(excludes=excludes,escape=escape))
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.spanning_segment));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.spanning_segment));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->__pyx_base.spanning_segment));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ID, __pyx_v_transcript_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_Parent, __pyx_v_gene_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_type, __pyx_v_rna_type) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3779; __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_3); __pyx_t_3 = 0;
  __pyx_v_feature = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":3780
 *         # mRNA feature
 *         feature = SegmentChain(self.spanning_segment,ID=transcript_id,Parent=gene_id,type=rna_type)
 *         ltmp.append(feature.as_gff3(excludes=excludes,escape=escape))             # <<<<<<<<<<<<<<
 * 
 *         # child features
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_feature), __pyx_n_s_as_gff3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_excludes, __pyx_v_excludes) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_escape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_escape, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_ltmp, __pyx_t_1); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3783
 * 
 *         # child features
 *         child_attr["Parent"] = transcript_id             # <<<<<<<<<<<<<<
 * 
 *         # exon feature
 */
  if (unlikely(__pyx_v_child_attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(PyDict_SetItem(__pyx_v_child_attr, __pyx_n_s_Parent, __pyx_v_transcript_id) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3786
 * 
 *         # exon feature
 *         child_attr["type"] = "exon"             # <<<<<<<<<<<<<<
 *         for n, seg in enumerate(self._segments):
 *             my_id   = "%s:exon:%s" % (transcript_id,n)
 */
  if (unlikely(__pyx_v_child_attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(PyDict_SetItem(__pyx_v_child_attr, __pyx_n_s_type, __pyx_n_s_exon) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3787
 *         # exon feature
 *         child_attr["type"] = "exon"
 *         for n, seg in enumerate(self._segments):             # <<<<<<<<<<<<<<
 *             my_id   = "%s:exon:%s" % (transcript_id,n)
 *             child_attr["ID"]   = my_id
 */
  __pyx_t_10 = 0;
  __pyx_t_1 = __pyx_v_self->__pyx_base._segments; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
  for (;;) {
    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 = 3787; __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 = 3787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_seg, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_n = __pyx_t_10;
    __pyx_t_10 = (__pyx_t_10 + 1);

    /* "plastid/genomics/roitools.pyx":3788
 *         child_attr["type"] = "exon"
 *         for n, seg in enumerate(self._segments):
 *             my_id   = "%s:exon:%s" % (transcript_id,n)             # <<<<<<<<<<<<<<
 *             child_attr["ID"]   = my_id
 *             feature = SegmentChain(seg,**child_attr)
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3788; __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 = 3788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_transcript_id);
    __Pyx_GIVEREF(__pyx_v_transcript_id);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_transcript_id);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_exon_s, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(PyString_CheckExact(__pyx_t_3))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_my_id, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "plastid/genomics/roitools.pyx":3789
 *         for n, seg in enumerate(self._segments):
 *             my_id   = "%s:exon:%s" % (transcript_id,n)
 *             child_attr["ID"]   = my_id             # <<<<<<<<<<<<<<
 *             feature = SegmentChain(seg,**child_attr)
 *             ltmp.append(SegmentChain.as_gff3(feature,excludes=excludes,escape=escape))
 */
    if (unlikely(__pyx_v_child_attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (unlikely(PyDict_SetItem(__pyx_v_child_attr, __pyx_n_s_ID, __pyx_v_my_id) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3790
 *             my_id   = "%s:exon:%s" % (transcript_id,n)
 *             child_attr["ID"]   = my_id
 *             feature = SegmentChain(seg,**child_attr)             # <<<<<<<<<<<<<<
 *             ltmp.append(SegmentChain.as_gff3(feature,excludes=excludes,escape=escape))
 * 
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_seg);
    __Pyx_GIVEREF(__pyx_v_seg);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_seg);
    if (unlikely(__pyx_v_child_attr == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_3, __pyx_v_child_attr); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_feature, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "plastid/genomics/roitools.pyx":3791
 *             child_attr["ID"]   = my_id
 *             feature = SegmentChain(seg,**child_attr)
 *             ltmp.append(SegmentChain.as_gff3(feature,excludes=excludes,escape=escape))             # <<<<<<<<<<<<<<
 * 
 *         # CDS & UTRs
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_n_s_as_gff3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3791; __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 = 3791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_feature));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_feature));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_feature));
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_excludes, __pyx_v_excludes) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_escape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_escape, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_ltmp, __pyx_t_2); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "plastid/genomics/roitools.pyx":3787
 *         # exon feature
 *         child_attr["type"] = "exon"
 *         for n, seg in enumerate(self._segments):             # <<<<<<<<<<<<<<
 *             my_id   = "%s:exon:%s" % (transcript_id,n)
 *             child_attr["ID"]   = my_id
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3794
 * 
 *         # CDS & UTRs
 *         if self.cds_genome_start is not None:             # <<<<<<<<<<<<<<
 *             parts = [("five_prime_UTR", self.get_utr5()),
 *                      ("CDS",            self.get_cds()),
 */
  __pyx_t_7 = (__pyx_v_self->cds_genome_start != Py_None);
  __pyx_t_6 = (__pyx_t_7 != 0);
  if (__pyx_t_6) {

    /* "plastid/genomics/roitools.pyx":3795
 *         # CDS & UTRs
 *         if self.cds_genome_start is not None:
 *             parts = [("five_prime_UTR", self.get_utr5()),             # <<<<<<<<<<<<<<
 *                      ("CDS",            self.get_cds()),
 *                      ("three_prime_UTR",self.get_utr3()),
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_utr5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    if (__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3795; __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(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_five_prime_UTR);
    __Pyx_GIVEREF(__pyx_n_s_five_prime_UTR);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_five_prime_UTR);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3796
 *         if self.cds_genome_start is not None:
 *             parts = [("five_prime_UTR", self.get_utr5()),
 *                      ("CDS",            self.get_cds()),             # <<<<<<<<<<<<<<
 *                      ("three_prime_UTR",self.get_utr3()),
 *                     ]
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_cds); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__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 = 3796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_n_s_CDS);
    __Pyx_GIVEREF(__pyx_n_s_CDS);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_CDS);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3797
 *             parts = [("five_prime_UTR", self.get_utr5()),
 *                      ("CDS",            self.get_cds()),
 *                      ("three_prime_UTR",self.get_utr3()),             # <<<<<<<<<<<<<<
 *                     ]
 *             for ftype, feature in parts:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_utr3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3797; __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(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_n_s_three_prime_UTR);
    __Pyx_GIVEREF(__pyx_n_s_three_prime_UTR);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_three_prime_UTR);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3795
 *         # CDS & UTRs
 *         if self.cds_genome_start is not None:
 *             parts = [("five_prime_UTR", self.get_utr5()),             # <<<<<<<<<<<<<<
 *                      ("CDS",            self.get_cds()),
 *                      ("three_prime_UTR",self.get_utr3()),
 */
    __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_8);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_1, 2, __pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_8 = 0;
    __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_parts, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3799
 *                      ("three_prime_UTR",self.get_utr3()),
 *                     ]
 *             for ftype, feature in parts:             # <<<<<<<<<<<<<<
 *                 child_attr["type"]   = ftype
 *                 child_attr["Parent"] = transcript_id
 */
    __pyx_t_1 = __pyx_v_parts; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    for (;;) {
      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 = 3799; __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 = 3799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      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 = 3799; __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_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_8 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_8)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        index = 1; __pyx_t_2 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L12_unpacking_done;
        __pyx_L11_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L12_unpacking_done:;
      }
      if (!(likely(PyString_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_8)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF_SET(__pyx_v_ftype, ((PyObject*)__pyx_t_8));
      __pyx_t_8 = 0;
      __Pyx_DECREF_SET(__pyx_v_feature, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_2));
      __pyx_t_2 = 0;

      /* "plastid/genomics/roitools.pyx":3800
 *                     ]
 *             for ftype, feature in parts:
 *                 child_attr["type"]   = ftype             # <<<<<<<<<<<<<<
 *                 child_attr["Parent"] = transcript_id
 *                 for n, seg in enumerate(feature):
 */
      if (unlikely(__pyx_v_child_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(PyDict_SetItem(__pyx_v_child_attr, __pyx_n_s_type, __pyx_v_ftype) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":3801
 *             for ftype, feature in parts:
 *                 child_attr["type"]   = ftype
 *                 child_attr["Parent"] = transcript_id             # <<<<<<<<<<<<<<
 *                 for n, seg in enumerate(feature):
 *                     my_id   = "%s:%s:%s" % (transcript_id,ftype,n)
 */
      if (unlikely(__pyx_v_child_attr == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (unlikely(PyDict_SetItem(__pyx_v_child_attr, __pyx_n_s_Parent, __pyx_v_transcript_id) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "plastid/genomics/roitools.pyx":3802
 *                 child_attr["type"]   = ftype
 *                 child_attr["Parent"] = transcript_id
 *                 for n, seg in enumerate(feature):             # <<<<<<<<<<<<<<
 *                     my_id   = "%s:%s:%s" % (transcript_id,ftype,n)
 *                     child_attr["ID"]   = my_id
 */
      __pyx_t_10 = 0;
      if (likely(PyList_CheckExact(((PyObject *)__pyx_v_feature))) || PyTuple_CheckExact(((PyObject *)__pyx_v_feature))) {
        __pyx_t_3 = ((PyObject *)__pyx_v_feature); __Pyx_INCREF(__pyx_t_3); __pyx_t_12 = 0;
        __pyx_t_13 = NULL;
      } else {
        __pyx_t_12 = -1; __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_feature)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_13 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      for (;;) {
        if (likely(!__pyx_t_13)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_12); __Pyx_INCREF(__pyx_t_2); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          } else {
            if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_12); __Pyx_INCREF(__pyx_t_2); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          }
        } else {
          __pyx_t_2 = __pyx_t_13(__pyx_t_3);
          if (unlikely(!__pyx_t_2)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XDECREF_SET(__pyx_v_seg, __pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_v_n = __pyx_t_10;
        __pyx_t_10 = (__pyx_t_10 + 1);

        /* "plastid/genomics/roitools.pyx":3803
 *                 child_attr["Parent"] = transcript_id
 *                 for n, seg in enumerate(feature):
 *                     my_id   = "%s:%s:%s" % (transcript_id,ftype,n)             # <<<<<<<<<<<<<<
 *                     child_attr["ID"]   = my_id
 *                     feature = SegmentChain(seg,**child_attr)
 */
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_v_transcript_id);
        __Pyx_GIVEREF(__pyx_v_transcript_id);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_transcript_id);
        __Pyx_INCREF(__pyx_v_ftype);
        __Pyx_GIVEREF(__pyx_v_ftype);
        PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_ftype);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s_s_4, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (!(likely(PyString_CheckExact(__pyx_t_2))||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_XDECREF_SET(__pyx_v_my_id, ((PyObject*)__pyx_t_2));
        __pyx_t_2 = 0;

        /* "plastid/genomics/roitools.pyx":3804
 *                 for n, seg in enumerate(feature):
 *                     my_id   = "%s:%s:%s" % (transcript_id,ftype,n)
 *                     child_attr["ID"]   = my_id             # <<<<<<<<<<<<<<
 *                     feature = SegmentChain(seg,**child_attr)
 *                     ltmp.append(feature.as_gff3(excludes=excludes,escape=escape))
 */
        if (unlikely(__pyx_v_child_attr == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        if (unlikely(PyDict_SetItem(__pyx_v_child_attr, __pyx_n_s_ID, __pyx_v_my_id) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "plastid/genomics/roitools.pyx":3805
 *                     my_id   = "%s:%s:%s" % (transcript_id,ftype,n)
 *                     child_attr["ID"]   = my_id
 *                     feature = SegmentChain(seg,**child_attr)             # <<<<<<<<<<<<<<
 *                     ltmp.append(feature.as_gff3(excludes=excludes,escape=escape))
 * 
 */
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_v_seg);
        __Pyx_GIVEREF(__pyx_v_seg);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_seg);
        if (unlikely(__pyx_v_child_attr == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_t_2, __pyx_v_child_attr); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF_SET(__pyx_v_feature, ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_8));
        __pyx_t_8 = 0;

        /* "plastid/genomics/roitools.pyx":3806
 *                     child_attr["ID"]   = my_id
 *                     feature = SegmentChain(seg,**child_attr)
 *                     ltmp.append(feature.as_gff3(excludes=excludes,escape=escape))             # <<<<<<<<<<<<<<
 * 
 *         return "".join(ltmp)
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_feature), __pyx_n_s_as_gff3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_excludes, __pyx_v_excludes) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_escape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_escape, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_ltmp, __pyx_t_4); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "plastid/genomics/roitools.pyx":3802
 *                 child_attr["type"]   = ftype
 *                 child_attr["Parent"] = transcript_id
 *                 for n, seg in enumerate(feature):             # <<<<<<<<<<<<<<
 *                     my_id   = "%s:%s:%s" % (transcript_id,ftype,n)
 *                     child_attr["ID"]   = my_id
 */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "plastid/genomics/roitools.pyx":3799
 *                      ("three_prime_UTR",self.get_utr3()),
 *                     ]
 *             for ftype, feature in parts:             # <<<<<<<<<<<<<<
 *                 child_attr["type"]   = ftype
 *                 child_attr["Parent"] = transcript_id
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "plastid/genomics/roitools.pyx":3794
 * 
 *         # CDS & UTRs
 *         if self.cds_genome_start is not None:             # <<<<<<<<<<<<<<
 *             parts = [("five_prime_UTR", self.get_utr5()),
 *                      ("CDS",            self.get_cds()),
 */
  }

  /* "plastid/genomics/roitools.pyx":3808
 *                     ltmp.append(feature.as_gff3(excludes=excludes,escape=escape))
 * 
 *         return "".join(ltmp)             # <<<<<<<<<<<<<<
 * 
 *     def as_bed(self,as_int=True,color=None,extra_columns=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyString_Join(__pyx_kp_s__16, __pyx_v_ltmp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3682
 *         return stmp
 * 
 *     def as_gff3(self, bint escape=True, list excludes=[], str rna_type="mRNA"):             # <<<<<<<<<<<<<<
 *         """Format a |Transcript| as a block of `GFF3`_ output, following
 *         the schema set out in the `Sequence Ontology (SO) v2.53 <http://www.sequenceontology.org/browser/>`_
 */

  /* function exit code */
  __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_8);
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.as_gff3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gene_id);
  __Pyx_XDECREF(__pyx_v_transcript_id);
  __Pyx_XDECREF(__pyx_v_ftype);
  __Pyx_XDECREF(__pyx_v_my_id);
  __Pyx_XDECREF(__pyx_v_ltmp);
  __Pyx_XDECREF(__pyx_v_parts);
  __Pyx_XDECREF(__pyx_v_child_attr);
  __Pyx_XDECREF((PyObject *)__pyx_v_feature);
  __Pyx_XDECREF(__pyx_v_keys_to_pop);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_seg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3810
 *         return "".join(ltmp)
 * 
 *     def as_bed(self,as_int=True,color=None,extra_columns=None):             # <<<<<<<<<<<<<<
 *         """Format `self` as a BED12[+X] line, assigning CDS boundaries
 *         to the thickstart and thickend columns from `self.attr`
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_27as_bed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_26as_bed[] = "Transcript.as_bed(self, as_int=True, color=None, extra_columns=None)\nFormat `self` as a BED12[+X] line, assigning CDS boundaries \n        to the thickstart and thickend columns from `self.attr`\n\n        If the |SegmentChain| was imported as a `BED`_ file with extra columns,\n        these will be output in the same order, after the `BED`_ columns.\n        \n        Parameters\n        ----------\n        as_int : bool, optional\n            Force \"score\" to integer (Default: True)\n    \n        color : str or None, optional\n            Color represented as RGB hex string.\n            If not none, overrides the color in `self.attr[\"color\"]`\n    \n        extra_columns : None or list, optional\n            If `None`, and the |Transcript| was imported using the `extra_columns`\n            keyword of :meth:`~plastid.genomics.roitools.Transcript.from_bed`,\n            the |Transcript| will be exported in BED 12+X format, in which\n            extra columns are in the same order as they were upon import. If no extra columns\n            were present, the |Transcript| will be exported a aa BED12 line.\n\n            If a list of attribute names, these attributes will be exported as\n            extra columns in order, overriding whatever happened upon import. \n            If an attribute name is not in the `attr` dict of the |Transcript|,\n            it will be exported with the default empty value \"\".\n\n            If an empty list, no extra columns will be exported; the |Transcript|\n            will be formatted as a BED12 line.\n\n    \n        Returns\n        -------\n        str\n            Line of BED12-formatted text\n            \n        \n        Notes\n        -----\n        BED12 columns are as follows\n            ======== =========\n            Column   Contains\n            ======== =========\n               0     Contig or chromosome\n               1     Start of first block in feature (0-indexed)\n               2     End of last bl""ock in feature (half-open)\n               3     Feature name\n               4     Feature score\n               5     Strand\n               6     thickstart\n               7     thickend\n               8     Feature color as RGB tuple\n               9     Number of blocks in feature\n               10    Block lengths\n               11    Block starts, relative to start of first block\n            ======== =========\n\n        Fore more information\n            See the `UCSC file format faq <http://genome.ucsc.edu/FAQ/FAQformat.html>`_\n        ";
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_27as_bed(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_as_int = 0;
  PyObject *__pyx_v_color = 0;
  PyObject *__pyx_v_extra_columns = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("as_bed (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_as_int,&__pyx_n_s_color,&__pyx_n_s_extra_columns,0};
    PyObject* values[3] = {0,0,0};
    values[0] = ((PyObject *)Py_True);
    values[1] = ((PyObject *)Py_None);
    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 (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_as_int);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_color);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_extra_columns);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "as_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3810; __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_as_int = values[0];
    __pyx_v_color = values[1];
    __pyx_v_extra_columns = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("as_bed", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3810; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.as_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_26as_bed(((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_v_self), __pyx_v_as_int, __pyx_v_color, __pyx_v_extra_columns);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_26as_bed(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_self, PyObject *__pyx_v_as_int, PyObject *__pyx_v_color, PyObject *__pyx_v_extra_columns) {
  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("as_bed", 0);

  /* "plastid/genomics/roitools.pyx":3871
 *             See the `UCSC file format faq <http://genome.ucsc.edu/FAQ/FAQformat.html>`_
 *         """
 *         return SegmentChain.as_bed(self,             # <<<<<<<<<<<<<<
 *                                    thickstart=self.cds_genome_start,
 *                                    thickend=self.cds_genome_end,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_n_s_as_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3871; __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 = 3871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));

  /* "plastid/genomics/roitools.pyx":3872
 *         """
 *         return SegmentChain.as_bed(self,
 *                                    thickstart=self.cds_genome_start,             # <<<<<<<<<<<<<<
 *                                    thickend=self.cds_genome_end,
 *                                    as_int=as_int,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_thickstart, __pyx_v_self->cds_genome_start) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3873
 *         return SegmentChain.as_bed(self,
 *                                    thickstart=self.cds_genome_start,
 *                                    thickend=self.cds_genome_end,             # <<<<<<<<<<<<<<
 *                                    as_int=as_int,
 *                                    color=color,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_thickend, __pyx_v_self->cds_genome_end) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3874
 *                                    thickstart=self.cds_genome_start,
 *                                    thickend=self.cds_genome_end,
 *                                    as_int=as_int,             # <<<<<<<<<<<<<<
 *                                    color=color,
 *                                    extra_columns=extra_columns)
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_as_int, __pyx_v_as_int) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3875
 *                                    thickend=self.cds_genome_end,
 *                                    as_int=as_int,
 *                                    color=color,             # <<<<<<<<<<<<<<
 *                                    extra_columns=extra_columns)
 * 
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_color, __pyx_v_color) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3876
 *                                    as_int=as_int,
 *                                    color=color,
 *                                    extra_columns=extra_columns)             # <<<<<<<<<<<<<<
 * 
 *     # TODO: optimize
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_extra_columns, __pyx_v_extra_columns) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3871
 *             See the `UCSC file format faq <http://genome.ucsc.edu/FAQ/FAQformat.html>`_
 *         """
 *         return SegmentChain.as_bed(self,             # <<<<<<<<<<<<<<
 *                                    thickstart=self.cds_genome_start,
 *                                    thickend=self.cds_genome_end,
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3871; __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_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3810
 *         return "".join(ltmp)
 * 
 *     def as_bed(self,as_int=True,color=None,extra_columns=None):             # <<<<<<<<<<<<<<
 *         """Format `self` as a BED12[+X] line, assigning CDS boundaries
 *         to the thickstart and thickend columns from `self.attr`
 */

  /* function exit code */
  __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("plastid.genomics.roitools.Transcript.as_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3880
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line,extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |Transcript| from a BED line with 4 or more columns.
 *         `thickstart` and `thickend` columns, if present, are assumed to specify
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_29from_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_28from_bed[] = "Transcript.from_bed(str line, extra_columns=0)\nCreate a |Transcript| from a BED line with 4 or more columns.\n        `thickstart` and `thickend` columns, if present, are assumed to specify\n        CDS boundaries, a convention that, while common, is formally outside the\n        `BED`_ specification.\n    \n    \tSee the `UCSC file format faq <http://genome.ucsc.edu/FAQ/FAQformat.html>`_\n    \tfor more details.\n\n        Parameters\n        ----------\n        line\n            Line from a BED file with at least 4 columns\n\n        extra_columns: int or list, optional\n            Extra, non-BED columns in `BED`_ file corresponding to feature\n            attributes. This is common in `ENCODE`_-specific `BED`_ variants.\n            \n            if `extra-columns` is:\n            \n              - an :class:`int`: it is taken to be the\n                number of attribute columns. Attributes will be stored in\n                the `attr` dictionary of the |SegmentChain|, under names like\n                `custom0`, `custom1`, ... , `customN`.\n\n              - a :class:`list` of :class:`str`, it is taken to be the names\n                of the attribute columns, in order, from left to right in the file.\n                In this case, attributes in extra columns will be stored under\n\n              - a :class:`list` of :class:`tuple`, each tuple is taken\n                to be a pair of `(attribute_name, formatter_func)`. In this case,\n                the value of `attribute_name` in the `attr` dict of the |SegmentChain|\n                will be set to `formatter_func(column_value)`.\n            \n            (Default: 0)\n                \n    \n        Returns\n        -------\n        |Transcript|\n        ";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_10Transcript_29from_bed = {"from_bed", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_29from_bed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_28from_bed};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_29from_bed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_line = 0;
  PyObject *__pyx_v_extra_columns = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_bed (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_line,&__pyx_n_s_extra_columns,0};
    PyObject* values[2] = {0,0};
    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 (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_line)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_extra_columns);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "from_bed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __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_line = ((PyObject*)values[0]);
    __pyx_v_extra_columns = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_bed", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.from_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_line), (&PyString_Type), 1, "line", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_28from_bed(__pyx_v_line, __pyx_v_extra_columns);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_28from_bed(PyObject *__pyx_v_line, PyObject *__pyx_v_extra_columns) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_segchain = 0;
  PyObject *__pyx_v_segments = 0;
  PyObject *__pyx_v_attr = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_transcript = 0;
  PyObject *__pyx_v_cds_genome_start = NULL;
  PyObject *__pyx_v_cds_genome_end = 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;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_bed", 0);

  /* "plastid/genomics/roitools.pyx":3922
 *         """
 *         cdef:
 *             SegmentChain segchain = SegmentChain.from_bed(line,extra_columns=extra_columns)             # <<<<<<<<<<<<<<
 *             list segments = segchain._segments
 *             dict attr = segchain.attr
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_n_s_from_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3922; __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 = 3922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_line);
  __Pyx_GIVEREF(__pyx_v_line);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_line);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_extra_columns, __pyx_v_extra_columns) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3922; __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_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_segchain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":3923
 *         cdef:
 *             SegmentChain segchain = SegmentChain.from_bed(line,extra_columns=extra_columns)
 *             list segments = segchain._segments             # <<<<<<<<<<<<<<
 *             dict attr = segchain.attr
 *             Transcript transcript = Transcript()
 */
  __pyx_t_4 = __pyx_v_segchain->_segments;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_segments = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":3924
 *             SegmentChain segchain = SegmentChain.from_bed(line,extra_columns=extra_columns)
 *             list segments = segchain._segments
 *             dict attr = segchain.attr             # <<<<<<<<<<<<<<
 *             Transcript transcript = Transcript()
 * 
 */
  __pyx_t_4 = __pyx_v_segchain->attr;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_attr = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":3925
 *             list segments = segchain._segments
 *             dict attr = segchain.attr
 *             Transcript transcript = Transcript()             # <<<<<<<<<<<<<<
 * 
 *         transcript._set_segments(segments)
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_transcript = ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":3927
 *             Transcript transcript = Transcript()
 * 
 *         transcript._set_segments(segments)             # <<<<<<<<<<<<<<
 * 
 *         cds_genome_start = attr.get("thickstart",None)
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_transcript->__pyx_base.__pyx_vtab)->__pyx_base._set_segments(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_transcript), __pyx_v_segments); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3929
 *         transcript._set_segments(segments)
 * 
 *         cds_genome_start = attr.get("thickstart",None)             # <<<<<<<<<<<<<<
 *         cds_genome_end   = attr.get("thickend",None)
 * 
 */
  if (unlikely(__pyx_v_attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_attr, __pyx_n_s_thickstart, Py_None); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_cds_genome_start = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":3930
 * 
 *         cds_genome_start = attr.get("thickstart",None)
 *         cds_genome_end   = attr.get("thickend",None)             # <<<<<<<<<<<<<<
 * 
 *         if cds_genome_start == cds_genome_end:
 */
  if (unlikely(__pyx_v_attr == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = __Pyx_PyDict_GetItemDefault(__pyx_v_attr, __pyx_n_s_thickend, Py_None); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_cds_genome_end = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":3932
 *         cds_genome_end   = attr.get("thickend",None)
 * 
 *         if cds_genome_start == cds_genome_end:             # <<<<<<<<<<<<<<
 *             cds_genome_start = cds_genome_end = None
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_cds_genome_start, __pyx_v_cds_genome_end, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_5) {

    /* "plastid/genomics/roitools.pyx":3933
 * 
 *         if cds_genome_start == cds_genome_end:
 *             cds_genome_start = cds_genome_end = None             # <<<<<<<<<<<<<<
 * 
 *         transcript.cds_genome_start = cds_genome_start
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF_SET(__pyx_v_cds_genome_start, Py_None);
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF_SET(__pyx_v_cds_genome_end, Py_None);

    /* "plastid/genomics/roitools.pyx":3932
 *         cds_genome_end   = attr.get("thickend",None)
 * 
 *         if cds_genome_start == cds_genome_end:             # <<<<<<<<<<<<<<
 *             cds_genome_start = cds_genome_end = None
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":3935
 *             cds_genome_start = cds_genome_end = None
 * 
 *         transcript.cds_genome_start = cds_genome_start             # <<<<<<<<<<<<<<
 *         transcript.cds_genome_end = cds_genome_end
 * 
 */
  __Pyx_INCREF(__pyx_v_cds_genome_start);
  __Pyx_GIVEREF(__pyx_v_cds_genome_start);
  __Pyx_GOTREF(__pyx_v_transcript->cds_genome_start);
  __Pyx_DECREF(__pyx_v_transcript->cds_genome_start);
  __pyx_v_transcript->cds_genome_start = __pyx_v_cds_genome_start;

  /* "plastid/genomics/roitools.pyx":3936
 * 
 *         transcript.cds_genome_start = cds_genome_start
 *         transcript.cds_genome_end = cds_genome_end             # <<<<<<<<<<<<<<
 * 
 *         if transcript.cds_genome_start is not None and transcript.cds_genome_end is not None:
 */
  __Pyx_INCREF(__pyx_v_cds_genome_end);
  __Pyx_GIVEREF(__pyx_v_cds_genome_end);
  __Pyx_GOTREF(__pyx_v_transcript->cds_genome_end);
  __Pyx_DECREF(__pyx_v_transcript->cds_genome_end);
  __pyx_v_transcript->cds_genome_end = __pyx_v_cds_genome_end;

  /* "plastid/genomics/roitools.pyx":3938
 *         transcript.cds_genome_end = cds_genome_end
 * 
 *         if transcript.cds_genome_start is not None and transcript.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 *             transcript._update_cds()
 * 
 */
  __pyx_t_6 = (__pyx_v_transcript->cds_genome_start != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {
  } else {
    __pyx_t_5 = __pyx_t_7;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_7 = (__pyx_v_transcript->cds_genome_end != Py_None);
  __pyx_t_6 = (__pyx_t_7 != 0);
  __pyx_t_5 = __pyx_t_6;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_5) {

    /* "plastid/genomics/roitools.pyx":3939
 * 
 *         if transcript.cds_genome_start is not None and transcript.cds_genome_end is not None:
 *             transcript._update_cds()             # <<<<<<<<<<<<<<
 * 
 *         attr["type"] = "mRNA" # default type for SegmentChain is "exon". We want to use "mRNA"
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_transcript->__pyx_base.__pyx_vtab)->_update_cds(__pyx_v_transcript); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "plastid/genomics/roitools.pyx":3938
 *         transcript.cds_genome_end = cds_genome_end
 * 
 *         if transcript.cds_genome_start is not None and transcript.cds_genome_end is not None:             # <<<<<<<<<<<<<<
 *             transcript._update_cds()
 * 
 */
  }

  /* "plastid/genomics/roitools.pyx":3941
 *             transcript._update_cds()
 * 
 *         attr["type"] = "mRNA" # default type for SegmentChain is "exon". We want to use "mRNA"             # <<<<<<<<<<<<<<
 *         attr.pop("thickstart")
 *         attr.pop("thickend")
 */
  if (unlikely(__pyx_v_attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_type, __pyx_n_s_mRNA) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3942
 * 
 *         attr["type"] = "mRNA" # default type for SegmentChain is "exon". We want to use "mRNA"
 *         attr.pop("thickstart")             # <<<<<<<<<<<<<<
 *         attr.pop("thickend")
 *         transcript.attr = attr
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_attr, __pyx_n_s_pop); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3942; __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_3); __pyx_t_3 = 0;

  /* "plastid/genomics/roitools.pyx":3943
 *         attr["type"] = "mRNA" # default type for SegmentChain is "exon". We want to use "mRNA"
 *         attr.pop("thickstart")
 *         attr.pop("thickend")             # <<<<<<<<<<<<<<
 *         transcript.attr = attr
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_attr, __pyx_n_s_pop); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3943; __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_4); __pyx_t_4 = 0;

  /* "plastid/genomics/roitools.pyx":3944
 *         attr.pop("thickstart")
 *         attr.pop("thickend")
 *         transcript.attr = attr             # <<<<<<<<<<<<<<
 * 
 *         return transcript
 */
  __Pyx_INCREF(__pyx_v_attr);
  __Pyx_GIVEREF(__pyx_v_attr);
  __Pyx_GOTREF(__pyx_v_transcript->__pyx_base.attr);
  __Pyx_DECREF(__pyx_v_transcript->__pyx_base.attr);
  __pyx_v_transcript->__pyx_base.attr = __pyx_v_attr;

  /* "plastid/genomics/roitools.pyx":3946
 *         transcript.attr = attr
 * 
 *         return transcript             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_transcript));
  __pyx_r = ((PyObject *)__pyx_v_transcript);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3880
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line,extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |Transcript| from a BED line with 4 or more columns.
 *         `thickstart` and `thickend` columns, if present, are assumed to specify
 */

  /* function exit code */
  __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("plastid.genomics.roitools.Transcript.from_bed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_segchain);
  __Pyx_XDECREF(__pyx_v_segments);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XDECREF((PyObject *)__pyx_v_transcript);
  __Pyx_XDECREF(__pyx_v_cds_genome_start);
  __Pyx_XDECREF(__pyx_v_cds_genome_end);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "plastid/genomics/roitools.pyx":3949
 * 
 *     @staticmethod
 *     def from_psl(str psl_line):             # <<<<<<<<<<<<<<
 *         cdef:
 *             Transcript transcript = Transcript()
 */

/* Python wrapper */
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_31from_psl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_7plastid_8genomics_8roitools_10Transcript_30from_psl[] = "Transcript.from_psl(str psl_line)";
static PyMethodDef __pyx_mdef_7plastid_8genomics_8roitools_10Transcript_31from_psl = {"from_psl", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_31from_psl, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_30from_psl};
static PyObject *__pyx_pw_7plastid_8genomics_8roitools_10Transcript_31from_psl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_psl_line = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("from_psl (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_psl_line,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_psl_line)) != 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, "from_psl") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __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_psl_line = ((PyObject*)values[0]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("from_psl", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("plastid.genomics.roitools.Transcript.from_psl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_psl_line), (&PyString_Type), 1, "psl_line", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_7plastid_8genomics_8roitools_10Transcript_30from_psl(__pyx_v_psl_line);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7plastid_8genomics_8roitools_10Transcript_30from_psl(PyObject *__pyx_v_psl_line) {
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *__pyx_v_transcript = 0;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *__pyx_v_segchain = 0;
  PyObject *__pyx_v_attr = 0;
  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_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("from_psl", 0);

  /* "plastid/genomics/roitools.pyx":3951
 *     def from_psl(str psl_line):
 *         cdef:
 *             Transcript transcript = Transcript()             # <<<<<<<<<<<<<<
 *             SegmentChain segchain = SegmentChain.from_psl(psl_line)
 *             dict attr = segchain.attr
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_transcript = ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3952
 *         cdef:
 *             Transcript transcript = Transcript()
 *             SegmentChain segchain = SegmentChain.from_psl(psl_line)             # <<<<<<<<<<<<<<
 *             dict attr = segchain.attr
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain), __pyx_n_s_from_psl); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_psl_line); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_psl_line);
    __Pyx_GIVEREF(__pyx_v_psl_line);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_psl_line);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_segchain = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3953
 *             Transcript transcript = Transcript()
 *             SegmentChain segchain = SegmentChain.from_psl(psl_line)
 *             dict attr = segchain.attr             # <<<<<<<<<<<<<<
 * 
 *         attr["cds_genome_start"] = None
 */
  __pyx_t_1 = __pyx_v_segchain->attr;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_attr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3955
 *             dict attr = segchain.attr
 * 
 *         attr["cds_genome_start"] = None             # <<<<<<<<<<<<<<
 *         attr["cds_genome_end"]   = None
 *         transcript._set_segments(segchain._segments)
 */
  if (unlikely(__pyx_v_attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_cds_genome_start, Py_None) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3956
 * 
 *         attr["cds_genome_start"] = None
 *         attr["cds_genome_end"]   = None             # <<<<<<<<<<<<<<
 *         transcript._set_segments(segchain._segments)
 *         transcript.attr = attr
 */
  if (unlikely(__pyx_v_attr == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (unlikely(PyDict_SetItem(__pyx_v_attr, __pyx_n_s_cds_genome_end, Py_None) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3957
 *         attr["cds_genome_start"] = None
 *         attr["cds_genome_end"]   = None
 *         transcript._set_segments(segchain._segments)             # <<<<<<<<<<<<<<
 *         transcript.attr = attr
 * 
 */
  __pyx_t_1 = __pyx_v_segchain->_segments;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = ((struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript *)__pyx_v_transcript->__pyx_base.__pyx_vtab)->__pyx_base._set_segments(((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)__pyx_v_transcript), ((PyObject*)__pyx_t_1)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3958
 *         attr["cds_genome_end"]   = None
 *         transcript._set_segments(segchain._segments)
 *         transcript.attr = attr             # <<<<<<<<<<<<<<
 * 
 *         return transcript
 */
  __Pyx_INCREF(__pyx_v_attr);
  __Pyx_GIVEREF(__pyx_v_attr);
  __Pyx_GOTREF(__pyx_v_transcript->__pyx_base.attr);
  __Pyx_DECREF(__pyx_v_transcript->__pyx_base.attr);
  __pyx_v_transcript->__pyx_base.attr = __pyx_v_attr;

  /* "plastid/genomics/roitools.pyx":3960
 *         transcript.attr = attr
 * 
 *         return transcript             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_transcript));
  __pyx_r = ((PyObject *)__pyx_v_transcript);
  goto __pyx_L0;

  /* "plastid/genomics/roitools.pyx":3949
 * 
 *     @staticmethod
 *     def from_psl(str psl_line):             # <<<<<<<<<<<<<<
 *         cdef:
 *             Transcript transcript = Transcript()
 */

  /* function exit code */
  __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("plastid.genomics.roitools.Transcript.from_psl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_transcript);
  __Pyx_XDECREF((PyObject *)__pyx_v_segchain);
  __Pyx_XDECREF(__pyx_v_attr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":91
 *             __data_union data
 * 
 *         def __getbuffer__(self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_7cpython_5array_5array_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_7cpython_5array_5array_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_7cpython_5array_5array___getbuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7cpython_5array_5array___getbuffer__(arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info, CYTHON_UNUSED int __pyx_v_flags) {
  PyObject *__pyx_v_item_count = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  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);
  }

  /* "array.pxd":96
 *             # In particular strided access is always provided regardless
 *             # of flags
 *             item_count = Py_SIZE(self)             # <<<<<<<<<<<<<<
 * 
 *             info.suboffsets = NULL
 */
  __pyx_t_1 = PyInt_FromSsize_t(Py_SIZE(((PyObject *)__pyx_v_self))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_item_count = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "array.pxd":98
 *             item_count = Py_SIZE(self)
 * 
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.buf = self.data.as_chars
 *             info.readonly = 0
 */
  __pyx_v_info->suboffsets = NULL;

  /* "array.pxd":99
 * 
 *             info.suboffsets = NULL
 *             info.buf = self.data.as_chars             # <<<<<<<<<<<<<<
 *             info.readonly = 0
 *             info.ndim = 1
 */
  __pyx_t_2 = __pyx_v_self->data.as_chars;
  __pyx_v_info->buf = __pyx_t_2;

  /* "array.pxd":100
 *             info.suboffsets = NULL
 *             info.buf = self.data.as_chars
 *             info.readonly = 0             # <<<<<<<<<<<<<<
 *             info.ndim = 1
 *             info.itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 */
  __pyx_v_info->readonly = 0;

  /* "array.pxd":101
 *             info.buf = self.data.as_chars
 *             info.readonly = 0
 *             info.ndim = 1             # <<<<<<<<<<<<<<
 *             info.itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 *             info.len = info.itemsize * item_count
 */
  __pyx_v_info->ndim = 1;

  /* "array.pxd":102
 *             info.readonly = 0
 *             info.ndim = 1
 *             info.itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)             # <<<<<<<<<<<<<<
 *             info.len = info.itemsize * item_count
 * 
 */
  __pyx_t_3 = __pyx_v_self->ob_descr->itemsize;
  __pyx_v_info->itemsize = __pyx_t_3;

  /* "array.pxd":103
 *             info.ndim = 1
 *             info.itemsize = self.ob_descr.itemsize   # e.g. sizeof(float)
 *             info.len = info.itemsize * item_count             # <<<<<<<<<<<<<<
 * 
 *             info.shape = <Py_ssize_t*> PyMem_Malloc(sizeof(Py_ssize_t) + 2)
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_info->itemsize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyNumber_Multiply(__pyx_t_1, __pyx_v_item_count); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_info->len = __pyx_t_5;

  /* "array.pxd":105
 *             info.len = info.itemsize * item_count
 * 
 *             info.shape = <Py_ssize_t*> PyMem_Malloc(sizeof(Py_ssize_t) + 2)             # <<<<<<<<<<<<<<
 *             if not info.shape:
 *                 raise MemoryError()
 */
  __pyx_v_info->shape = ((Py_ssize_t *)PyMem_Malloc(((sizeof(Py_ssize_t)) + 2)));

  /* "array.pxd":106
 * 
 *             info.shape = <Py_ssize_t*> PyMem_Malloc(sizeof(Py_ssize_t) + 2)
 *             if not info.shape:             # <<<<<<<<<<<<<<
 *                 raise MemoryError()
 *             info.shape[0] = item_count      # constant regardless of resizing
 */
  __pyx_t_6 = ((!(__pyx_v_info->shape != 0)) != 0);
  if (__pyx_t_6) {

    /* "array.pxd":107
 *             info.shape = <Py_ssize_t*> PyMem_Malloc(sizeof(Py_ssize_t) + 2)
 *             if not info.shape:
 *                 raise MemoryError()             # <<<<<<<<<<<<<<
 *             info.shape[0] = item_count      # constant regardless of resizing
 *             info.strides = &info.itemsize
 */
    PyErr_NoMemory(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "array.pxd":106
 * 
 *             info.shape = <Py_ssize_t*> PyMem_Malloc(sizeof(Py_ssize_t) + 2)
 *             if not info.shape:             # <<<<<<<<<<<<<<
 *                 raise MemoryError()
 *             info.shape[0] = item_count      # constant regardless of resizing
 */
  }

  /* "array.pxd":108
 *             if not info.shape:
 *                 raise MemoryError()
 *             info.shape[0] = item_count      # constant regardless of resizing             # <<<<<<<<<<<<<<
 *             info.strides = &info.itemsize
 * 
 */
  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_item_count); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  (__pyx_v_info->shape[0]) = __pyx_t_5;

  /* "array.pxd":109
 *                 raise MemoryError()
 *             info.shape[0] = item_count      # constant regardless of resizing
 *             info.strides = &info.itemsize             # <<<<<<<<<<<<<<
 * 
 *             info.format = <char*> (info.shape + 1)
 */
  __pyx_v_info->strides = (&__pyx_v_info->itemsize);

  /* "array.pxd":111
 *             info.strides = &info.itemsize
 * 
 *             info.format = <char*> (info.shape + 1)             # <<<<<<<<<<<<<<
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0
 */
  __pyx_v_info->format = ((char *)(__pyx_v_info->shape + 1));

  /* "array.pxd":112
 * 
 *             info.format = <char*> (info.shape + 1)
 *             info.format[0] = self.ob_descr.typecode             # <<<<<<<<<<<<<<
 *             info.format[1] = 0
 *             info.obj = self
 */
  __pyx_t_3 = __pyx_v_self->ob_descr->typecode;
  (__pyx_v_info->format[0]) = __pyx_t_3;

  /* "array.pxd":113
 *             info.format = <char*> (info.shape + 1)
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0             # <<<<<<<<<<<<<<
 *             info.obj = self
 * 
 */
  (__pyx_v_info->format[1]) = 0;

  /* "array.pxd":114
 *             info.format[0] = self.ob_descr.typecode
 *             info.format[1] = 0
 *             info.obj = self             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(self, Py_buffer* info):
 */
  __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);

  /* "array.pxd":91
 *             __data_union data
 * 
 *         def __getbuffer__(self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cpython.array.array.__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(__pyx_v_item_count);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":116
 *             info.obj = self
 * 
 *         def __releasebuffer__(self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             PyMem_Free(info.shape)
 * 
 */

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_7cpython_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_7cpython_5array_5array_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_7cpython_5array_5array_2__releasebuffer__(((arrayobject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_7cpython_5array_5array_2__releasebuffer__(CYTHON_UNUSED arrayobject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "array.pxd":117
 * 
 *         def __releasebuffer__(self, Py_buffer* info):
 *             PyMem_Free(info.shape)             # <<<<<<<<<<<<<<
 * 
 *     array newarrayobject(PyTypeObject* type, Py_ssize_t size, arraydescr *descr)
 */
  PyMem_Free(__pyx_v_info->shape);

  /* "array.pxd":116
 *             info.obj = self
 * 
 *         def __releasebuffer__(self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             PyMem_Free(info.shape)
 * 
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "array.pxd":128
 * 
 * 
 * cdef inline array clone(array template, Py_ssize_t length, bint zero):             # <<<<<<<<<<<<<<
 *     """ fast creation of a new array, given a template array.
 *     type will be same as template.
 */

static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_clone(arrayobject *__pyx_v_template, Py_ssize_t __pyx_v_length, int __pyx_v_zero) {
  arrayobject *__pyx_v_op = NULL;
  arrayobject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("clone", 0);

  /* "array.pxd":132
 *     type will be same as template.
 *     if zero is true, new array will be initialized with zeroes."""
 *     op = newarrayobject(Py_TYPE(template), length, template.ob_descr)             # <<<<<<<<<<<<<<
 *     if zero and op is not None:
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
 */
  __pyx_t_1 = ((PyObject *)newarrayobject(Py_TYPE(((PyObject *)__pyx_v_template)), __pyx_v_length, __pyx_v_template->ob_descr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((arrayobject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "array.pxd":133
 *     if zero is true, new array will be initialized with zeroes."""
 *     op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
 *     if zero and op is not None:             # <<<<<<<<<<<<<<
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
 *     return op
 */
  __pyx_t_3 = (__pyx_v_zero != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (((PyObject *)__pyx_v_op) != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "array.pxd":134
 *     op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
 *     if zero and op is not None:
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 *     return op
 * 
 */
    memset(__pyx_v_op->data.as_chars, 0, (__pyx_v_length * __pyx_v_op->ob_descr->itemsize));

    /* "array.pxd":133
 *     if zero is true, new array will be initialized with zeroes."""
 *     op = newarrayobject(Py_TYPE(template), length, template.ob_descr)
 *     if zero and op is not None:             # <<<<<<<<<<<<<<
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
 *     return op
 */
  }

  /* "array.pxd":135
 *     if zero and op is not None:
 *         memset(op.data.as_chars, 0, length * op.ob_descr.itemsize)
 *     return op             # <<<<<<<<<<<<<<
 * 
 * cdef inline array copy(array self):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_op));
  __pyx_r = __pyx_v_op;
  goto __pyx_L0;

  /* "array.pxd":128
 * 
 * 
 * cdef inline array clone(array template, Py_ssize_t length, bint zero):             # <<<<<<<<<<<<<<
 *     """ fast creation of a new array, given a template array.
 *     type will be same as template.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpython.array.clone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_op);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":137
 *     return op
 * 
 * cdef inline array copy(array self):             # <<<<<<<<<<<<<<
 *     """ make a copy of an array. """
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
 */

static CYTHON_INLINE arrayobject *__pyx_f_7cpython_5array_copy(arrayobject *__pyx_v_self) {
  arrayobject *__pyx_v_op = NULL;
  arrayobject *__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("copy", 0);

  /* "array.pxd":139
 * cdef inline array copy(array self):
 *     """ make a copy of an array. """
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)             # <<<<<<<<<<<<<<
 *     memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)
 *     return op
 */
  __pyx_t_1 = ((PyObject *)newarrayobject(Py_TYPE(((PyObject *)__pyx_v_self)), Py_SIZE(((PyObject *)__pyx_v_self)), __pyx_v_self->ob_descr)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_op = ((arrayobject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "array.pxd":140
 *     """ make a copy of an array. """
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
 *     memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 *     return op
 * 
 */
  memcpy(__pyx_v_op->data.as_chars, __pyx_v_self->data.as_chars, (Py_SIZE(((PyObject *)__pyx_v_op)) * __pyx_v_op->ob_descr->itemsize));

  /* "array.pxd":141
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
 *     memcpy(op.data.as_chars, self.data.as_chars, Py_SIZE(op) * op.ob_descr.itemsize)
 *     return op             # <<<<<<<<<<<<<<
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_op));
  __pyx_r = __pyx_v_op;
  goto __pyx_L0;

  /* "array.pxd":137
 *     return op
 * 
 * cdef inline array copy(array self):             # <<<<<<<<<<<<<<
 *     """ make a copy of an array. """
 *     op = newarrayobject(Py_TYPE(self), Py_SIZE(self), self.ob_descr)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cpython.array.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_op);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":143
 *     return op
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:             # <<<<<<<<<<<<<<
 *     """ efficent appending of new stuff of same type
 *     (e.g. of same array type)
 */

static CYTHON_INLINE int __pyx_f_7cpython_5array_extend_buffer(arrayobject *__pyx_v_self, char *__pyx_v_stuff, Py_ssize_t __pyx_v_n) {
  Py_ssize_t __pyx_v_itemsize;
  Py_ssize_t __pyx_v_origsize;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend_buffer", 0);

  /* "array.pxd":147
 *     (e.g. of same array type)
 *     n: number of elements (not number of bytes!) """
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t origsize = Py_SIZE(self)
 *     resize_smart(self, origsize + n)
 */
  __pyx_t_1 = __pyx_v_self->ob_descr->itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "array.pxd":148
 *     n: number of elements (not number of bytes!) """
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize
 *     cdef Py_ssize_t origsize = Py_SIZE(self)             # <<<<<<<<<<<<<<
 *     resize_smart(self, origsize + n)
 *     memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
 */
  __pyx_v_origsize = Py_SIZE(((PyObject *)__pyx_v_self));

  /* "array.pxd":149
 *     cdef Py_ssize_t itemsize = self.ob_descr.itemsize
 *     cdef Py_ssize_t origsize = Py_SIZE(self)
 *     resize_smart(self, origsize + n)             # <<<<<<<<<<<<<<
 *     memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
 *     return 0
 */
  __pyx_t_1 = resize_smart(__pyx_v_self, (__pyx_v_origsize + __pyx_v_n)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "array.pxd":150
 *     cdef Py_ssize_t origsize = Py_SIZE(self)
 *     resize_smart(self, origsize + n)
 *     memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  memcpy((__pyx_v_self->data.as_chars + (__pyx_v_origsize * __pyx_v_itemsize)), __pyx_v_stuff, (__pyx_v_n * __pyx_v_itemsize));

  /* "array.pxd":151
 *     resize_smart(self, origsize + n)
 *     memcpy(self.data.as_chars + origsize * itemsize, stuff, n * itemsize)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef inline int extend(array self, array other) except -1:
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "array.pxd":143
 *     return op
 * 
 * cdef inline int extend_buffer(array self, char* stuff, Py_ssize_t n) except -1:             # <<<<<<<<<<<<<<
 *     """ efficent appending of new stuff of same type
 *     (e.g. of same array type)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpython.array.extend_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":153
 *     return 0
 * 
 * cdef inline int extend(array self, array other) except -1:             # <<<<<<<<<<<<<<
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:
 */

static CYTHON_INLINE int __pyx_f_7cpython_5array_extend(arrayobject *__pyx_v_self, arrayobject *__pyx_v_other) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extend", 0);

  /* "array.pxd":155
 * cdef inline int extend(array self, array other) except -1:
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:             # <<<<<<<<<<<<<<
 *         PyErr_BadArgument()
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 */
  __pyx_t_1 = ((__pyx_v_self->ob_descr->typecode != __pyx_v_other->ob_descr->typecode) != 0);
  if (__pyx_t_1) {

    /* "array.pxd":156
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:
 *         PyErr_BadArgument()             # <<<<<<<<<<<<<<
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 * 
 */
    __pyx_t_2 = PyErr_BadArgument(); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "array.pxd":155
 * cdef inline int extend(array self, array other) except -1:
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:             # <<<<<<<<<<<<<<
 *         PyErr_BadArgument()
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 */
  }

  /* "array.pxd":157
 *     if self.ob_descr.typecode != other.ob_descr.typecode:
 *         PyErr_BadArgument()
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))             # <<<<<<<<<<<<<<
 * 
 * cdef inline void zero(array self):
 */
  __pyx_t_2 = __pyx_f_7cpython_5array_extend_buffer(__pyx_v_self, __pyx_v_other->data.as_chars, Py_SIZE(((PyObject *)__pyx_v_other))); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "array.pxd":153
 *     return 0
 * 
 * cdef inline int extend(array self, array other) except -1:             # <<<<<<<<<<<<<<
 *     """ extend array with data from another array; types must match. """
 *     if self.ob_descr.typecode != other.ob_descr.typecode:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("cpython.array.extend", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "array.pxd":159
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 * 
 * cdef inline void zero(array self):             # <<<<<<<<<<<<<<
 *     """ set all elements of array to zero. """
 *     memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)
 */

static CYTHON_INLINE void __pyx_f_7cpython_5array_zero(arrayobject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("zero", 0);

  /* "array.pxd":161
 * cdef inline void zero(array self):
 *     """ set all elements of array to zero. """
 *     memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)             # <<<<<<<<<<<<<<
 */
  memset(__pyx_v_self->data.as_chars, 0, (Py_SIZE(((PyObject *)__pyx_v_self)) * __pyx_v_self->ob_descr->itemsize));

  /* "array.pxd":159
 *     return extend_buffer(self, other.data.as_chars, Py_SIZE(other))
 * 
 * cdef inline void zero(array self):             # <<<<<<<<<<<<<<
 *     """ set all elements of array to zero. """
 *     memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":197
 *         # 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.
 */

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

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char *__pyx_t_7;
  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);
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":203
 *             # of flags
 * 
 *             if info == NULL: return             # <<<<<<<<<<<<<<
 * 
 *             cdef int copy_shape, i, ndim
 */
  __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":206
 * 
 *             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;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":207
 *             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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":209
 *             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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":211
 *             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))) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":212
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 copy_shape = 0
 */
    __pyx_v_copy_shape = 1;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":211
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
    goto __pyx_L4;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":214
 *                 copy_shape = 1
 *             else:
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
  /*else*/ {
    __pyx_v_copy_shape = 0;
  }
  __pyx_L4:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":216
 *                 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_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L6_bool_binop_done;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":217
 * 
 *             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) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L6_bool_binop_done:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":216
 *                 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")
 */
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":218
 *             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_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __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[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":216
 *                 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")
 */
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":220
 *                 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_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L9_bool_binop_done;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":221
 * 
 *             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_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L9_bool_binop_done:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":220
 *                 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")
 */
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":222
 *             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_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __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[3]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":220
 *                 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")
 */
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":224
 *                 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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":225
 * 
 *             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;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":226
 *             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.
 */
  __pyx_t_1 = (__pyx_v_copy_shape != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":229
 *                 # 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)));

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":230
 *                 # 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);

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":231
 *                 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_4 = __pyx_v_ndim;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":232
 *                 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]);

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":233
 *                 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]);
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":226
 *             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.
 */
    goto __pyx_L11;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":235
 *                     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
 */
  /*else*/ {
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":236
 *             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_L11:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":237
 *                 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;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":238
 *                 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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":239
 *             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) != 0));

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":242
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = self.descr
 *             cdef int offset
 */
  __pyx_v_f = NULL;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":243
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 *             cdef int offset
 * 
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->descr);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":246
 *             cdef int offset
 * 
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields and not copy_shape:
 */
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":248
 *             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 != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L15_bool_binop_done;
  }
  __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L15_bool_binop_done:;
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":250
 *             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;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":248
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
    goto __pyx_L14;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":253
 *             else:
 *                 # need to call releasebuffer
 *                 info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields:
 */
  /*else*/ {
    __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_L14:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":255
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":256
 * 
 *             if not hasfields:
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 */
    __pyx_t_4 = __pyx_v_descr->type_num;
    __pyx_v_t = __pyx_t_4;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":257
 *             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_2 = ((__pyx_v_descr->byteorder == '>') != 0);
    if (!__pyx_t_2) {
      goto __pyx_L20_next_or;
    } else {
    }
    __pyx_t_2 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_L20_next_or:;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":258
 *                 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_2 = ((__pyx_v_descr->byteorder == '<') != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L19_bool_binop_done;
    }
    __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L19_bool_binop_done:;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":257
 *             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")
 */
    if (__pyx_t_1) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":259
 *                 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_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 259; __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[3]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":257
 *             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")
 */
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":260
 *                     (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"
 */
    switch (__pyx_v_t) {
      case NPY_BYTE:
      __pyx_v_f = __pyx_k_b;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":261
 *                     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"
 */
      case NPY_UBYTE:
      __pyx_v_f = __pyx_k_B;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":262
 *                 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"
 */
      case NPY_SHORT:
      __pyx_v_f = __pyx_k_h;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":263
 *                 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"
 */
      case NPY_USHORT:
      __pyx_v_f = __pyx_k_H;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":264
 *                 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"
 */
      case NPY_INT:
      __pyx_v_f = __pyx_k_i;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":265
 *                 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"
 */
      case NPY_UINT:
      __pyx_v_f = __pyx_k_I;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":266
 *                 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"
 */
      case NPY_LONG:
      __pyx_v_f = __pyx_k_l;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":267
 *                 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"
 */
      case NPY_ULONG:
      __pyx_v_f = __pyx_k_L;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":268
 *                 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"
 */
      case NPY_LONGLONG:
      __pyx_v_f = __pyx_k_q;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":269
 *                 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"
 */
      case NPY_ULONGLONG:
      __pyx_v_f = __pyx_k_Q;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":270
 *                 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"
 */
      case NPY_FLOAT:
      __pyx_v_f = __pyx_k_f;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":271
 *                 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"
 */
      case NPY_DOUBLE:
      __pyx_v_f = __pyx_k_d;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":272
 *                 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"
 */
      case NPY_LONGDOUBLE:
      __pyx_v_f = __pyx_k_g;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":273
 *                 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"
 */
      case NPY_CFLOAT:
      __pyx_v_f = __pyx_k_Zf;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 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"
 */
      case NPY_CDOUBLE:
      __pyx_v_f = __pyx_k_Zd;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":275
 *                 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:
 */
      case NPY_CLONGDOUBLE:
      __pyx_v_f = __pyx_k_Zg;
      break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":276
 *                 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)
 */
      case NPY_OBJECT:
      __pyx_v_f = __pyx_k_O;
      break;
      default:

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":278
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      break;
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":279
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":280
 *                     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;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":255
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":282
 *                 return
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 */
  /*else*/ {
    __pyx_v_info->format = ((char *)malloc(0xFF));

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":283
 *             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]) = '^';

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":284
 *                 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;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":285
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,             # <<<<<<<<<<<<<<
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 */
    __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_f = __pyx_t_7;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":288
 *                                       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';
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":197
 *         # 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.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __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;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":290
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

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

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":291
 * 
 *         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) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":292
 *         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);

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":291
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":293
 *             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))) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":294
 *                 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);

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":293
 *             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
 */
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":290
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":770
 * 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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":771
 * 
 * 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[3]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":770
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

  /* function exit code */
  __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;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":773
 *     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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":774
 * 
 * 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[3]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":773
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

  /* function exit code */
  __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;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":776
 *     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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":777
 * 
 * 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[3]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":776
 *     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)
 * 
 */

  /* function exit code */
  __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;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":779
 *     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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":780
 * 
 * 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[3]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":779
 *     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)
 * 
 */

  /* function exit code */
  __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;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":782
 *     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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":783
 * 
 * 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[3]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":782
 *     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)
 * 
 */

  /* function exit code */
  __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;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":785
 *     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;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  long __pyx_t_8;
  char *__pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_util_dtypestring", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":790
 * 
 *     cdef dtype child
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 *     cdef tuple fields
 */
  __pyx_v_endian_detector = 1;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":791
 *     cdef dtype child
 *     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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":794
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  if (unlikely(__pyx_v_descr->names == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[3]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __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[3]; __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[3]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":795
 * 
 *     for childname in descr.names:
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 *         child, new_offset = fields
 * 
 */
    if (unlikely(__pyx_v_descr->fields == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[3]; __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 %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":796
 *     for childname in descr.names:
 *         fields = descr.fields[childname]
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 */
    if (likely(__pyx_v_fields != Py_None)) {
      PyObject* sequence = __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[3]; __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[3]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":798
 *         child, new_offset = fields
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __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_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0);
    if (__pyx_t_6) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":799
 * 
 *         if (end - f) - <int>(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_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 799; __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[3]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":798
 *         child, new_offset = fields
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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 == '>') != 0);
    if (!__pyx_t_7) {
      goto __pyx_L8_next_or;
    } else {
    }
    __pyx_t_7 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_L8_next_or:;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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 == '<') != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L7_bool_binop_done:;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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")
 */
    if (__pyx_t_6) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 803; __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[3]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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")
 */
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":813
 * 
 *         # Output padding bytes
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 */
    while (1) {
      __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_6) break;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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]) = 0x78;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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);

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":816
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 * 
 *         offset[0] += child.itemsize
 */
      __pyx_t_8 = 0;
      (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":818
 *             offset[0] += 1
 * 
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not PyDataType_HASFIELDS(child):
 */
    __pyx_t_8 = 0;
    (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":820
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
    __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
    if (__pyx_t_6) {

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
      if (__pyx_t_6) {

        /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 823; __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[3]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":822
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 98;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 66;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x68;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 72;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x69;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 73;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x6C;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 76;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x71;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 81;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x66;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x64;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x67;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x66;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x64;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x67;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 79;
        goto __pyx_L15;
      }

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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:
 */
      /*else*/ {
        __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 844; __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[3]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__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[3]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L15:;

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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);

      /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":820
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
      goto __pyx_L13;
    }

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":849
 *             # Cython ignores struct boundary information ("T{...}"),
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 *     return f
 * 
 */
    /*else*/ {
      __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_f = __pyx_t_9;
    }
    __pyx_L13:;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":794
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":850
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)
 *     return f             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_f;
  goto __pyx_L0;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":785
 *     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.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __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;
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":966
 * 
 * 
 * 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;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("set_array_base", 0);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":968
 * 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);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":969
 *      cdef PyObject* baseptr
 *      if base is None:
 *          baseptr = NULL             # <<<<<<<<<<<<<<
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 */
    __pyx_v_baseptr = NULL;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":968
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
    goto __pyx_L3;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":971
 *          baseptr = NULL
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 */
  /*else*/ {
    Py_INCREF(__pyx_v_base);

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":972
 *      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:;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":973
 *          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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":974
 *          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;

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":976
 *      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);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":977
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
  if (__pyx_t_1) {

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":978
 * 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;

    /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":977
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":980
 *         return None
 *     else:
 *         return <object>arr.base             # <<<<<<<<<<<<<<
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
    __pyx_r = ((PyObject *)__pyx_v_arr->base);
    goto __pyx_L0;
  }

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":118
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

/* Python wrapper */
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_shape = 0;
  Py_ssize_t __pyx_v_itemsize;
  PyObject *__pyx_v_format = 0;
  PyObject *__pyx_v_mode = 0;
  int __pyx_v_allocate_buffer;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[3] = ((PyObject *)__pyx_n_s_c);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        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_shape)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allocate_buffer);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        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);
        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_shape = ((PyObject*)values[0]);
    __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_format = values[2];
    __pyx_v_mode = values[3];
    if (values[4]) {
      __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {

      /* "View.MemoryView":119
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
 *                   mode="c", bint allocate_buffer=True):             # <<<<<<<<<<<<<<
 * 
 *         cdef int idx
 */
      __pyx_v_allocate_buffer = ((int)1);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
    PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer);

  /* "View.MemoryView":118
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) {
  int __pyx_v_idx;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_dim;
  PyObject **__pyx_v_p;
  char __pyx_v_order;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  char *__pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__cinit__", 0);
  __Pyx_INCREF(__pyx_v_format);

  /* "View.MemoryView":125
 *         cdef PyObject **p
 * 
 *         self.ndim = <int> len(shape)             # <<<<<<<<<<<<<<
 *         self.itemsize = itemsize
 * 
 */
  if (unlikely(__pyx_v_shape == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->ndim = ((int)__pyx_t_1);

  /* "View.MemoryView":126
 * 
 *         self.ndim = <int> len(shape)
 *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not self.ndim:
 */
  __pyx_v_self->itemsize = __pyx_v_itemsize;

  /* "View.MemoryView":128
 *         self.itemsize = itemsize
 * 
 *         if not self.ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":129
 * 
 *         if not self.ndim:
 *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if itemsize <= 0:
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 129; __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[4]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":128
 *         self.itemsize = itemsize
 * 
 *         if not self.ndim:             # <<<<<<<<<<<<<<
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 */
  }

  /* "View.MemoryView":131
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 *         if itemsize <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 */
  __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":132
 * 
 *         if itemsize <= 0:
 *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(format, bytes):
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 132; __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[4]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":131
 *             raise ValueError("Empty shape tuple for cython.array")
 * 
 *         if itemsize <= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 */
  }

  /* "View.MemoryView":134
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
 *             format = format.encode('ASCII')
 *         self._format = format  # keep a reference to the byte string
 */
  __pyx_t_2 = PyBytes_Check(__pyx_v_format); 
  __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":135
 * 
 *         if not isinstance(format, bytes):
 *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "View.MemoryView":134
 *             raise ValueError("itemsize <= 0 for cython.array")
 * 
 *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
 *             format = format.encode('ASCII')
 *         self._format = format  # keep a reference to the byte string
 */
  }

  /* "View.MemoryView":136
 *         if not isinstance(format, bytes):
 *             format = format.encode('ASCII')
 *         self._format = format  # keep a reference to the byte string             # <<<<<<<<<<<<<<
 *         self.format = self._format
 * 
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __pyx_v_format;
  __Pyx_INCREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_GOTREF(__pyx_v_self->_format);
  __Pyx_DECREF(__pyx_v_self->_format);
  __pyx_v_self->_format = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "View.MemoryView":137
 *             format = format.encode('ASCII')
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_self->_format); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->format = __pyx_t_6;

  /* "View.MemoryView":140
 * 
 * 
 *         self._shape = <Py_ssize_t *> PyMem_Malloc(sizeof(Py_ssize_t)*self.ndim*2)             # <<<<<<<<<<<<<<
 *         self._strides = self._shape + self.ndim
 * 
 */
  __pyx_v_self->_shape = ((Py_ssize_t *)PyMem_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));

  /* "View.MemoryView":141
 * 
 *         self._shape = <Py_ssize_t *> PyMem_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
 *         self._strides = self._shape + self.ndim             # <<<<<<<<<<<<<<
 * 
 *         if not self._shape:
 */
  __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);

  /* "View.MemoryView":143
 *         self._strides = self._shape + self.ndim
 * 
 *         if not self._shape:             # <<<<<<<<<<<<<<
 *             raise MemoryError("unable to allocate shape and strides.")
 * 
 */
  __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":144
 * 
 *         if not self._shape:
 *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __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[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":143
 *         self._strides = self._shape + self.ndim
 * 
 *         if not self._shape:             # <<<<<<<<<<<<<<
 *             raise MemoryError("unable to allocate shape and strides.")
 * 
 */
  }

  /* "View.MemoryView":147
 * 
 * 
 *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 */
  __pyx_t_7 = 0;
  __pyx_t_5 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_dim = __pyx_t_8;
    __pyx_v_idx = __pyx_t_7;
    __pyx_t_7 = (__pyx_t_7 + 1);

    /* "View.MemoryView":148
 * 
 *         for idx, dim in enumerate(shape):
 *             if dim <= 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 *             self._shape[idx] = dim
 */
    __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":149
 *         for idx, dim in enumerate(shape):
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))             # <<<<<<<<<<<<<<
 *             self._shape[idx] = dim
 * 
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
      __pyx_t_3 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":148
 * 
 *         for idx, dim in enumerate(shape):
 *             if dim <= 0:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 *             self._shape[idx] = dim
 */
    }

    /* "View.MemoryView":150
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 *             self._shape[idx] = dim             # <<<<<<<<<<<<<<
 * 
 *         cdef char order
 */
    (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;

    /* "View.MemoryView":147
 * 
 * 
 *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
 *             if dim <= 0:
 *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "View.MemoryView":153
 * 
 *         cdef char order
 *         if mode == 'fortran':             # <<<<<<<<<<<<<<
 *             order = b'F'
 *             self.mode = u'fortran'
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "View.MemoryView":154
 *         cdef char order
 *         if mode == 'fortran':
 *             order = b'F'             # <<<<<<<<<<<<<<
 *             self.mode = u'fortran'
 *         elif mode == 'c':
 */
    __pyx_v_order = 'F';

    /* "View.MemoryView":155
 *         if mode == 'fortran':
 *             order = b'F'
 *             self.mode = u'fortran'             # <<<<<<<<<<<<<<
 *         elif mode == 'c':
 *             order = b'C'
 */
    __Pyx_INCREF(__pyx_n_u_fortran);
    __Pyx_GIVEREF(__pyx_n_u_fortran);
    __Pyx_GOTREF(__pyx_v_self->mode);
    __Pyx_DECREF(__pyx_v_self->mode);
    __pyx_v_self->mode = __pyx_n_u_fortran;

    /* "View.MemoryView":153
 * 
 *         cdef char order
 *         if mode == 'fortran':             # <<<<<<<<<<<<<<
 *             order = b'F'
 *             self.mode = u'fortran'
 */
    goto __pyx_L10;
  }

  /* "View.MemoryView":156
 *             order = b'F'
 *             self.mode = u'fortran'
 *         elif mode == 'c':             # <<<<<<<<<<<<<<
 *             order = b'C'
 *             self.mode = u'c'
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "View.MemoryView":157
 *             self.mode = u'fortran'
 *         elif mode == 'c':
 *             order = b'C'             # <<<<<<<<<<<<<<
 *             self.mode = u'c'
 *         else:
 */
    __pyx_v_order = 'C';

    /* "View.MemoryView":158
 *         elif mode == 'c':
 *             order = b'C'
 *             self.mode = u'c'             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
 */
    __Pyx_INCREF(__pyx_n_u_c);
    __Pyx_GIVEREF(__pyx_n_u_c);
    __Pyx_GOTREF(__pyx_v_self->mode);
    __Pyx_DECREF(__pyx_v_self->mode);
    __pyx_v_self->mode = __pyx_n_u_c;

    /* "View.MemoryView":156
 *             order = b'F'
 *             self.mode = u'fortran'
 *         elif mode == 'c':             # <<<<<<<<<<<<<<
 *             order = b'C'
 *             self.mode = u'c'
 */
    goto __pyx_L10;
  }

  /* "View.MemoryView":160
 *             self.mode = u'c'
 *         else:
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)             # <<<<<<<<<<<<<<
 * 
 *         self.len = fill_contig_strides_array(self._shape, self._strides,
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L10:;

  /* "View.MemoryView":162
 *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
 * 
 *         self.len = fill_contig_strides_array(self._shape, self._strides,             # <<<<<<<<<<<<<<
 *                                              itemsize, self.ndim, order)
 * 
 */
  __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order);

  /* "View.MemoryView":165
 *                                              itemsize, self.ndim, order)
 * 
 *         self.free_data = allocate_buffer             # <<<<<<<<<<<<<<
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:
 */
  __pyx_v_self->free_data = __pyx_v_allocate_buffer;

  /* "View.MemoryView":166
 * 
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'             # <<<<<<<<<<<<<<
 *         if allocate_buffer:
 * 
 */
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_self->dtype_is_object = __pyx_t_4;

  /* "View.MemoryView":167
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
  if (__pyx_t_4) {

    /* "View.MemoryView":170
 * 
 * 
 *             self.data = <char *>malloc(self.len)             # <<<<<<<<<<<<<<
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")
 */
    __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));

    /* "View.MemoryView":171
 * 
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:             # <<<<<<<<<<<<<<
 *                 raise MemoryError("unable to allocate array data.")
 * 
 */
    __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":172
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
 * 
 *             if self.dtype_is_object:
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 172; __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[4]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":171
 * 
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:             # <<<<<<<<<<<<<<
 *                 raise MemoryError("unable to allocate array data.")
 * 
 */
    }

    /* "View.MemoryView":174
 *                 raise MemoryError("unable to allocate array data.")
 * 
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 */
    __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":175
 * 
 *             if self.dtype_is_object:
 *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None
 */
      __pyx_v_p = ((PyObject **)__pyx_v_self->data);

      /* "View.MemoryView":176
 *             if self.dtype_is_object:
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):             # <<<<<<<<<<<<<<
 *                     p[i] = Py_None
 *                     Py_INCREF(Py_None)
 */
      if (unlikely(__pyx_v_itemsize == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
        {__pyx_filename = __pyx_f[4]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) {
        PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
        {__pyx_filename = __pyx_f[4]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
      for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
        __pyx_v_i = __pyx_t_8;

        /* "View.MemoryView":177
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None             # <<<<<<<<<<<<<<
 *                     Py_INCREF(Py_None)
 * 
 */
        (__pyx_v_p[__pyx_v_i]) = Py_None;

        /* "View.MemoryView":178
 *                 for i in range(self.len / itemsize):
 *                     p[i] = Py_None
 *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
        Py_INCREF(Py_None);
      }

      /* "View.MemoryView":174
 *                 raise MemoryError("unable to allocate array data.")
 * 
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 p = <PyObject **> self.data
 *                 for i in range(self.len / itemsize):
 */
    }

    /* "View.MemoryView":167
 *         self.free_data = allocate_buffer
 *         self.dtype_is_object = format == b'O'
 *         if allocate_buffer:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":118
 *         cdef bint dtype_is_object
 * 
 *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
 *                   mode="c", bint allocate_buffer=True):
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_format);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":181
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_array_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_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_bufmode;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  char *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t *__pyx_t_7;
  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);
  }

  /* "View.MemoryView":182
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         cdef int bufmode = -1             # <<<<<<<<<<<<<<
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 */
  __pyx_v_bufmode = -1;

  /* "View.MemoryView":183
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         cdef int bufmode = -1
 *         if self.mode == u"c":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":
 */
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":184
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 */
    __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);

    /* "View.MemoryView":183
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         cdef int bufmode = -1
 *         if self.mode == u"c":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":185
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 */
  __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":186
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 */
    __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);

    /* "View.MemoryView":185
 *         if self.mode == u"c":
 *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 */
  }
  __pyx_L3:;

  /* "View.MemoryView":187
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data
 */
  __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":188
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
 *         info.buf = self.data
 *         info.len = self.len
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 188; __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[4]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":187
 *         elif self.mode == u"fortran":
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data
 */
  }

  /* "View.MemoryView":189
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data             # <<<<<<<<<<<<<<
 *         info.len = self.len
 *         info.ndim = self.ndim
 */
  __pyx_t_4 = __pyx_v_self->data;
  __pyx_v_info->buf = __pyx_t_4;

  /* "View.MemoryView":190
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")
 *         info.buf = self.data
 *         info.len = self.len             # <<<<<<<<<<<<<<
 *         info.ndim = self.ndim
 *         info.shape = self._shape
 */
  __pyx_t_5 = __pyx_v_self->len;
  __pyx_v_info->len = __pyx_t_5;

  /* "View.MemoryView":191
 *         info.buf = self.data
 *         info.len = self.len
 *         info.ndim = self.ndim             # <<<<<<<<<<<<<<
 *         info.shape = self._shape
 *         info.strides = self._strides
 */
  __pyx_t_6 = __pyx_v_self->ndim;
  __pyx_v_info->ndim = __pyx_t_6;

  /* "View.MemoryView":192
 *         info.len = self.len
 *         info.ndim = self.ndim
 *         info.shape = self._shape             # <<<<<<<<<<<<<<
 *         info.strides = self._strides
 *         info.suboffsets = NULL
 */
  __pyx_t_7 = __pyx_v_self->_shape;
  __pyx_v_info->shape = __pyx_t_7;

  /* "View.MemoryView":193
 *         info.ndim = self.ndim
 *         info.shape = self._shape
 *         info.strides = self._strides             # <<<<<<<<<<<<<<
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize
 */
  __pyx_t_7 = __pyx_v_self->_strides;
  __pyx_v_info->strides = __pyx_t_7;

  /* "View.MemoryView":194
 *         info.shape = self._shape
 *         info.strides = self._strides
 *         info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *         info.itemsize = self.itemsize
 *         info.readonly = 0
 */
  __pyx_v_info->suboffsets = NULL;

  /* "View.MemoryView":195
 *         info.strides = self._strides
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize             # <<<<<<<<<<<<<<
 *         info.readonly = 0
 * 
 */
  __pyx_t_5 = __pyx_v_self->itemsize;
  __pyx_v_info->itemsize = __pyx_t_5;

  /* "View.MemoryView":196
 *         info.suboffsets = NULL
 *         info.itemsize = self.itemsize
 *         info.readonly = 0             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
  __pyx_v_info->readonly = 0;

  /* "View.MemoryView":198
 *         info.readonly = 0
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.format
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":199
 * 
 *         if flags & PyBUF_FORMAT:
 *             info.format = self.format             # <<<<<<<<<<<<<<
 *         else:
 *             info.format = NULL
 */
    __pyx_t_4 = __pyx_v_self->format;
    __pyx_v_info->format = __pyx_t_4;

    /* "View.MemoryView":198
 *         info.readonly = 0
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.format
 *         else:
 */
    goto __pyx_L5;
  }

  /* "View.MemoryView":201
 *             info.format = self.format
 *         else:
 *             info.format = NULL             # <<<<<<<<<<<<<<
 * 
 *         info.obj = self
 */
  /*else*/ {
    __pyx_v_info->format = NULL;
  }
  __pyx_L5:;

  /* "View.MemoryView":203
 *             info.format = NULL
 * 
 *         info.obj = self             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 */
  __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);

  /* "View.MemoryView":181
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         cdef int bufmode = -1
 *         if self.mode == u"c":
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.array.__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_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":207
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 * 
 *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 */

/* Python wrapper */
static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

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

  /* "View.MemoryView":208
 * 
 *     def __dealloc__(array self):
 *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 */
  __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":209
 *     def __dealloc__(array self):
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)             # <<<<<<<<<<<<<<
 *         elif self.free_data:
 *             if self.dtype_is_object:
 */
    __pyx_v_self->callback_free_data(__pyx_v_self->data);

    /* "View.MemoryView":208
 * 
 *     def __dealloc__(array self):
 *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":210
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 *         elif self.free_data:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 refcount_objects_in_slice(self.data, self._shape,
 */
  __pyx_t_1 = (__pyx_v_self->free_data != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":211
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 refcount_objects_in_slice(self.data, self._shape,
 *                                           self._strides, self.ndim, False)
 */
    __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":212
 *         elif self.free_data:
 *             if self.dtype_is_object:
 *                 refcount_objects_in_slice(self.data, self._shape,             # <<<<<<<<<<<<<<
 *                                           self._strides, self.ndim, False)
 *             free(self.data)
 */
      __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);

      /* "View.MemoryView":211
 *             self.callback_free_data(self.data)
 *         elif self.free_data:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 refcount_objects_in_slice(self.data, self._shape,
 *                                           self._strides, self.ndim, False)
 */
    }

    /* "View.MemoryView":214
 *                 refcount_objects_in_slice(self.data, self._shape,
 *                                           self._strides, self.ndim, False)
 *             free(self.data)             # <<<<<<<<<<<<<<
 *         PyMem_Free(self._shape)
 * 
 */
    free(__pyx_v_self->data);

    /* "View.MemoryView":210
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 *         elif self.free_data:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 refcount_objects_in_slice(self.data, self._shape,
 */
  }
  __pyx_L3:;

  /* "View.MemoryView":215
 *                                           self._strides, self.ndim, False)
 *             free(self.data)
 *         PyMem_Free(self._shape)             # <<<<<<<<<<<<<<
 * 
 *     property memview:
 */
  PyMem_Free(__pyx_v_self->_shape);

  /* "View.MemoryView":207
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
 * 
 *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
 *         if self.callback_free_data != NULL:
 *             self.callback_free_data(self.data)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":219
 *     property memview:
 *         @cname('get_memview')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 * 
 *             flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 */

/* Python wrapper */
static PyObject *get_memview(PyObject *__pyx_v_self); /*proto*/
static PyObject *get_memview(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
  int __pyx_v_flags;
  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("__get__", 0);

  /* "View.MemoryView":221
 *         def __get__(self):
 * 
 *             flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE             # <<<<<<<<<<<<<<
 *             return  memoryview(self, flags, self.dtype_is_object)
 * 
 */
  __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);

  /* "View.MemoryView":222
 * 
 *             flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 *             return  memoryview(self, flags, self.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 222; __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[4]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":219
 *     property memview:
 *         @cname('get_memview')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 * 
 *             flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":225
 * 
 * 
 *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
 *         return getattr(self.memview, attr)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/
static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
  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("__getattr__", 0);

  /* "View.MemoryView":226
 * 
 *     def __getattr__(self, attr):
 *         return getattr(self.memview, attr)             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, item):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 226; __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;

  /* "View.MemoryView":225
 * 
 * 
 *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
 *         return getattr(self.memview, attr)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":228
 *         return getattr(self.memview, attr)
 * 
 *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
 *         return self.memview[item]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
  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);

  /* "View.MemoryView":229
 * 
 *     def __getitem__(self, item):
 *         return self.memview[item]             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, item, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 229; __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;

  /* "View.MemoryView":228
 *         return getattr(self.memview, attr)
 * 
 *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
 *         return self.memview[item]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":231
 *         return self.memview[item]
 * 
 *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
 *         self.memview[item] = value
 * 
 */

/* Python wrapper */
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/
static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
  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("__setitem__", 0);

  /* "View.MemoryView":232
 * 
 *     def __setitem__(self, item, value):
 *         self.memview[item] = value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":231
 *         return self.memview[item]
 * 
 *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
 *         self.memview[item] = value
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":236
 * 
 * @cname("__pyx_array_new")
 * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
 *                           char *mode, char *buf):
 *     cdef array result
 */

static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) {
  struct __pyx_array_obj *__pyx_v_result = 0;
  struct __pyx_array_obj *__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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("array_cwrapper", 0);

  /* "View.MemoryView":240
 *     cdef array result
 * 
 *     if buf == NULL:             # <<<<<<<<<<<<<<
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":241
 * 
 *     if buf == NULL:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))             # <<<<<<<<<<<<<<
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "View.MemoryView":240
 *     cdef array result
 * 
 *     if buf == NULL:             # <<<<<<<<<<<<<<
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":243
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
 *                        allocate_buffer=False)
 *         result.data = buf
 */
  /*else*/ {
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_3 = 0;

    /* "View.MemoryView":244
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 *                        allocate_buffer=False)             # <<<<<<<<<<<<<<
 *         result.data = buf
 * 
 */
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":243
 *         result = array(shape, itemsize, format, mode.decode('ASCII'))
 *     else:
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
 *                        allocate_buffer=False)
 *         result.data = buf
 */
    __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __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_result = ((struct __pyx_array_obj *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "View.MemoryView":245
 *         result = array(shape, itemsize, format, mode.decode('ASCII'),
 *                        allocate_buffer=False)
 *         result.data = buf             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
    __pyx_v_result->data = __pyx_v_buf;
  }
  __pyx_L3:;

  /* "View.MemoryView":247
 *         result.data = buf
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "View.MemoryView":236
 * 
 * @cname("__pyx_array_new")
 * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
 *                           char *mode, char *buf):
 *     cdef array result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":273
 * cdef class Enum(object):
 *     cdef object name
 *     def __init__(self, name):             # <<<<<<<<<<<<<<
 *         self.name = name
 *     def __repr__(self):
 */

/* Python wrapper */
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name_2,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_name_2)) != 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[4]; __pyx_lineno = 273; __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_name = 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[4]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "View.MemoryView":274
 *     cdef object name
 *     def __init__(self, name):
 *         self.name = name             # <<<<<<<<<<<<<<
 *     def __repr__(self):
 *         return self.name
 */
  __Pyx_INCREF(__pyx_v_name);
  __Pyx_GIVEREF(__pyx_v_name);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = __pyx_v_name;

  /* "View.MemoryView":273
 * cdef class Enum(object):
 *     cdef object name
 *     def __init__(self, name):             # <<<<<<<<<<<<<<
 *         self.name = name
 *     def __repr__(self):
 */

  /* function exit code */
  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":275
 *     def __init__(self, name):
 *         self.name = name
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return self.name
 * 
 */

/* Python wrapper */
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "View.MemoryView":276
 *         self.name = name
 *     def __repr__(self):
 *         return self.name             # <<<<<<<<<<<<<<
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

  /* "View.MemoryView":275
 *     def __init__(self, name):
 *         self.name = name
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return self.name
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":290
 * 
 * @cname('__pyx_align_pointer')
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
 */

static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
  Py_intptr_t __pyx_v_aligned_p;
  size_t __pyx_v_offset;
  void *__pyx_r;
  int __pyx_t_1;

  /* "View.MemoryView":292
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
 *     cdef size_t offset
 * 
 */
  __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);

  /* "View.MemoryView":296
 * 
 *     with cython.cdivision(True):
 *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
 * 
 *     if offset > 0:
 */
  __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);

  /* "View.MemoryView":298
 *         offset = aligned_p % alignment
 * 
 *     if offset > 0:             # <<<<<<<<<<<<<<
 *         aligned_p += alignment - offset
 * 
 */
  __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":299
 * 
 *     if offset > 0:
 *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
 * 
 *     return <void *> aligned_p
 */
    __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));

    /* "View.MemoryView":298
 *         offset = aligned_p % alignment
 * 
 *     if offset > 0:             # <<<<<<<<<<<<<<
 *         aligned_p += alignment - offset
 * 
 */
  }

  /* "View.MemoryView":301
 *         aligned_p += alignment - offset
 * 
 *     return <void *> aligned_p             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview')
 */
  __pyx_r = ((void *)__pyx_v_aligned_p);
  goto __pyx_L0;

  /* "View.MemoryView":290
 * 
 * @cname('__pyx_align_pointer')
 * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
 *     "Align pointer memory on a given boundary"
 *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":319
 *     cdef __Pyx_TypeInfo *typeinfo
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
 *         self.obj = obj
 *         self.flags = flags
 */

/* Python wrapper */
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  int __pyx_v_flags;
  int __pyx_v_dtype_is_object;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,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_obj)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype_is_object);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 319; __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_obj = values[0];
    __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[2]) {
      __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_dtype_is_object = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __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("__cinit__", 0);

  /* "View.MemoryView":320
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
 *         self.obj = obj             # <<<<<<<<<<<<<<
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:
 */
  __Pyx_INCREF(__pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __Pyx_GOTREF(__pyx_v_self->obj);
  __Pyx_DECREF(__pyx_v_self->obj);
  __pyx_v_self->obj = __pyx_v_obj;

  /* "View.MemoryView":321
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
 *         self.obj = obj
 *         self.flags = flags             # <<<<<<<<<<<<<<
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 */
  __pyx_v_self->flags = __pyx_v_flags;

  /* "View.MemoryView":322
 *         self.obj = obj
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 */
  __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = (__pyx_v_obj != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "View.MemoryView":323
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 */
    __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":324
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)
 */
    __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":325
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None             # <<<<<<<<<<<<<<
 *                 Py_INCREF(Py_None)
 * 
 */
      ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;

      /* "View.MemoryView":326
 *             if <PyObject *> self.view.obj == NULL:
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *         self.lock = PyThread_allocate_lock()
 */
      Py_INCREF(Py_None);

      /* "View.MemoryView":324
 *         if type(self) is memoryview or obj is not None:
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
 *                 (<__pyx_buffer *> &self.view).obj = Py_None
 *                 Py_INCREF(Py_None)
 */
    }

    /* "View.MemoryView":322
 *         self.obj = obj
 *         self.flags = flags
 *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_GetBuffer(obj, &self.view, flags)
 *             if <PyObject *> self.view.obj == NULL:
 */
  }

  /* "View.MemoryView":328
 *                 Py_INCREF(Py_None)
 * 
 *         self.lock = PyThread_allocate_lock()             # <<<<<<<<<<<<<<
 *         if self.lock == NULL:
 *             raise MemoryError
 */
  __pyx_v_self->lock = PyThread_allocate_lock();

  /* "View.MemoryView":329
 * 
 *         self.lock = PyThread_allocate_lock()
 *         if self.lock == NULL:             # <<<<<<<<<<<<<<
 *             raise MemoryError
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":330
 *         self.lock = PyThread_allocate_lock()
 *         if self.lock == NULL:
 *             raise MemoryError             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
    PyErr_NoMemory(); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":329
 * 
 *         self.lock = PyThread_allocate_lock()
 *         if self.lock == NULL:             # <<<<<<<<<<<<<<
 *             raise MemoryError
 * 
 */
  }

  /* "View.MemoryView":332
 *             raise MemoryError
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             self.dtype_is_object = self.view.format == b'O'
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":333
 * 
 *         if flags & PyBUF_FORMAT:
 *             self.dtype_is_object = self.view.format == b'O'             # <<<<<<<<<<<<<<
 *         else:
 *             self.dtype_is_object = dtype_is_object
 */
    __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_self->dtype_is_object = __pyx_t_1;

    /* "View.MemoryView":332
 *             raise MemoryError
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             self.dtype_is_object = self.view.format == b'O'
 *         else:
 */
    goto __pyx_L8;
  }

  /* "View.MemoryView":335
 *             self.dtype_is_object = self.view.format == b'O'
 *         else:
 *             self.dtype_is_object = dtype_is_object             # <<<<<<<<<<<<<<
 * 
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
 */
  /*else*/ {
    __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
  }
  __pyx_L8:;

  /* "View.MemoryView":337
 *             self.dtype_is_object = dtype_is_object
 * 
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
 *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
 *         self.typeinfo = NULL
 */
  __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));

  /* "View.MemoryView":339
 *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
 *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
 *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(memoryview self):
 */
  __pyx_v_self->typeinfo = NULL;

  /* "View.MemoryView":319
 *     cdef __Pyx_TypeInfo *typeinfo
 * 
 *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
 *         self.obj = obj
 *         self.flags = flags
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":341
 *         self.typeinfo = NULL
 * 
 *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)
 */

/* Python wrapper */
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "View.MemoryView":342
 * 
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 */
  __pyx_t_1 = (__pyx_v_self->obj != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":343
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
 * 
 *         if self.lock != NULL:
 */
    __Pyx_ReleaseBuffer((&__pyx_v_self->view));

    /* "View.MemoryView":342
 * 
 *     def __dealloc__(memoryview self):
 *         if self.obj is not None:             # <<<<<<<<<<<<<<
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 */
  }

  /* "View.MemoryView":345
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 *         if self.lock != NULL:             # <<<<<<<<<<<<<<
 *             PyThread_free_lock(self.lock)
 * 
 */
  __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":346
 * 
 *         if self.lock != NULL:
 *             PyThread_free_lock(self.lock)             # <<<<<<<<<<<<<<
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
 */
    PyThread_free_lock(__pyx_v_self->lock);

    /* "View.MemoryView":345
 *             __Pyx_ReleaseBuffer(&self.view)
 * 
 *         if self.lock != NULL:             # <<<<<<<<<<<<<<
 *             PyThread_free_lock(self.lock)
 * 
 */
  }

  /* "View.MemoryView":341
 *         self.typeinfo = NULL
 * 
 *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
 *         if self.obj is not None:
 *             __Pyx_ReleaseBuffer(&self.view)
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":348
 *             PyThread_free_lock(self.lock)
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf
 */

static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
  Py_ssize_t __pyx_v_dim;
  char *__pyx_v_itemp;
  PyObject *__pyx_v_idx = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  char *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_item_pointer", 0);

  /* "View.MemoryView":350
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
 * 
 *         for dim, idx in enumerate(index):
 */
  __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);

  /* "View.MemoryView":352
 *         cdef char *itemp = <char *> self.view.buf
 * 
 *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 */
  __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
    __pyx_t_2 = __pyx_v_index; __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_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(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[4]; __pyx_lineno = 352; __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[4]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        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[4]; __pyx_lineno = 352; __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[4]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_v_dim = __pyx_t_1;
    __pyx_t_1 = (__pyx_t_1 + 1);

    /* "View.MemoryView":353
 * 
 *         for dim, idx in enumerate(index):
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)             # <<<<<<<<<<<<<<
 * 
 *         return itemp
 */
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_itemp = __pyx_t_7;

    /* "View.MemoryView":352
 *         cdef char *itemp = <char *> self.view.buf
 * 
 *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":355
 *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
 * 
 *         return itemp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_itemp;
  goto __pyx_L0;

  /* "View.MemoryView":348
 *             PyThread_free_lock(self.lock)
 * 
 *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t dim
 *         cdef char *itemp = <char *> self.view.buf
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":358
 * 
 * 
 *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
 *         if index is Ellipsis:
 *             return self
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_v_have_slices = NULL;
  PyObject *__pyx_v_indices = NULL;
  char *__pyx_v_itemp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  char *__pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getitem__", 0);

  /* "View.MemoryView":359
 * 
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":360
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:
 *             return self             # <<<<<<<<<<<<<<
 * 
 *         have_slices, indices = _unellipsify(index, self.view.ndim)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __pyx_r = ((PyObject *)__pyx_v_self);
    goto __pyx_L0;

    /* "View.MemoryView":359
 * 
 *     def __getitem__(memoryview self, object index):
 *         if index is Ellipsis:             # <<<<<<<<<<<<<<
 *             return self
 * 
 */
  }

  /* "View.MemoryView":362
 *             return self
 * 
 *         have_slices, indices = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *         cdef char *itemp
 */
  __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(__pyx_t_3 != Py_None)) {
    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[4]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_have_slices = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_indices = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "View.MemoryView":365
 * 
 *         cdef char *itemp
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             return memview_slice(self, indices)
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "View.MemoryView":366
 *         cdef char *itemp
 *         if have_slices:
 *             return memview_slice(self, indices)             # <<<<<<<<<<<<<<
 *         else:
 *             itemp = self.get_item_pointer(indices)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":365
 * 
 *         cdef char *itemp
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             return memview_slice(self, indices)
 *         else:
 */
  }

  /* "View.MemoryView":368
 *             return memview_slice(self, indices)
 *         else:
 *             itemp = self.get_item_pointer(indices)             # <<<<<<<<<<<<<<
 *             return self.convert_item_to_object(itemp)
 * 
 */
  /*else*/ {
    __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_itemp = __pyx_t_6;

    /* "View.MemoryView":369
 *         else:
 *             itemp = self.get_item_pointer(indices)
 *             return self.convert_item_to_object(itemp)             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(memoryview self, object index, object value):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":358
 * 
 * 
 *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
 *         if index is Ellipsis:
 *             return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_have_slices);
  __Pyx_XDECREF(__pyx_v_indices);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":371
 *             return self.convert_item_to_object(itemp)
 * 
 *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 */

/* Python wrapper */
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_have_slices = NULL;
  PyObject *__pyx_v_obj = NULL;
  int __pyx_r;
  __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("__setitem__", 0);
  __Pyx_INCREF(__pyx_v_index);

  /* "View.MemoryView":372
 * 
 *     def __setitem__(memoryview self, object index, object value):
 *         have_slices, index = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *         if have_slices:
 */
  __pyx_t_1 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    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[4]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_have_slices = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "View.MemoryView":374
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             obj = self.is_slice(value)
 *             if obj:
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "View.MemoryView":375
 * 
 *         if have_slices:
 *             obj = self.is_slice(value)             # <<<<<<<<<<<<<<
 *             if obj:
 *                 self.setitem_slice_assignment(self[index], obj)
 */
    __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_obj = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "View.MemoryView":376
 *         if have_slices:
 *             obj = self.is_slice(value)
 *             if obj:             # <<<<<<<<<<<<<<
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 */
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_4) {

      /* "View.MemoryView":377
 *             obj = self.is_slice(value)
 *             if obj:
 *                 self.setitem_slice_assignment(self[index], obj)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.setitem_slice_assign_scalar(self[index], value)
 */
      __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_1, __pyx_v_obj); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 377; __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;

      /* "View.MemoryView":376
 *         if have_slices:
 *             obj = self.is_slice(value)
 *             if obj:             # <<<<<<<<<<<<<<
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 */
      goto __pyx_L4;
    }

    /* "View.MemoryView":379
 *                 self.setitem_slice_assignment(self[index], obj)
 *             else:
 *                 self.setitem_slice_assign_scalar(self[index], value)             # <<<<<<<<<<<<<<
 *         else:
 *             self.setitem_indexed(index, value)
 */
    /*else*/ {
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_3);
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_3), __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 379; __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;
    }
    __pyx_L4:;

    /* "View.MemoryView":374
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 *         if have_slices:             # <<<<<<<<<<<<<<
 *             obj = self.is_slice(value)
 *             if obj:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":381
 *                 self.setitem_slice_assign_scalar(self[index], value)
 *         else:
 *             self.setitem_indexed(index, value)             # <<<<<<<<<<<<<<
 * 
 *     cdef is_slice(self, obj):
 */
  /*else*/ {
    __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":371
 *             return self.convert_item_to_object(itemp)
 * 
 *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
 *         have_slices, index = _unellipsify(index, self.view.ndim)
 * 
 */

  /* function exit code */
  __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("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_have_slices);
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":383
 *             self.setitem_indexed(index, value)
 * 
 *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
 *         if not isinstance(obj, memoryview):
 *             try:
 */

static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  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;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_slice", 0);
  __Pyx_INCREF(__pyx_v_obj);

  /* "View.MemoryView":384
 * 
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":385
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 */
    {
      __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:*/ {

        /* "View.MemoryView":386
 *         if not isinstance(obj, memoryview):
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
 *                                  self.dtype_is_object)
 *             except TypeError:
 */
        __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_self->flags | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_6);

        /* "View.MemoryView":387
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)             # <<<<<<<<<<<<<<
 *             except TypeError:
 *                 return None
 */
        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_7);

        /* "View.MemoryView":386
 *         if not isinstance(obj, memoryview):
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
 *                                  self.dtype_is_object)
 *             except TypeError:
 */
        __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_v_obj);
        __Pyx_GIVEREF(__pyx_v_obj);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
        __pyx_t_6 = 0;
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
        __pyx_t_7 = 0;

        /* "View.MemoryView":385
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 */
      }
      __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_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "View.MemoryView":388
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 *             except TypeError:             # <<<<<<<<<<<<<<
 *                 return None
 * 
 */
      __pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_9) {
        __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_6);

        /* "View.MemoryView":389
 *                                  self.dtype_is_object)
 *             except TypeError:
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *         return obj
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_None);
        __pyx_r = Py_None;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L7_except_return;
      }
      goto __pyx_L6_except_error;
      __pyx_L6_except_error:;

      /* "View.MemoryView":385
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):
 *             try:             # <<<<<<<<<<<<<<
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 *                                  self.dtype_is_object)
 */
      __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_L11_try_end:;
    }

    /* "View.MemoryView":384
 * 
 *     cdef is_slice(self, obj):
 *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
 *             try:
 *                 obj = memoryview(obj, self.flags|PyBUF_ANY_CONTIGUOUS,
 */
  }

  /* "View.MemoryView":391
 *                 return None
 * 
 *         return obj             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_slice_assignment(self, dst, src):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_obj);
  __pyx_r = __pyx_v_obj;
  goto __pyx_L0;

  /* "View.MemoryView":383
 *             self.setitem_indexed(index, value)
 * 
 *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
 *         if not isinstance(obj, memoryview):
 *             try:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_obj);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":393
 *         return obj
 * 
 *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice dst_slice
 *         cdef __Pyx_memviewslice src_slice
 */

static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
  __Pyx_memviewslice __pyx_v_dst_slice;
  __Pyx_memviewslice __pyx_v_src_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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("setitem_slice_assignment", 0);

  /* "View.MemoryView":397
 *         cdef __Pyx_memviewslice src_slice
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 */
  if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":398
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
 *                                  get_slice_from_memview(dst, &dst_slice)[0],             # <<<<<<<<<<<<<<
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 */
  if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":399
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":397
 *         cdef __Pyx_memviewslice src_slice
 * 
 *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
 *                                  get_slice_from_memview(dst, &dst_slice)[0],
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 */
  __pyx_t_4 = __pyx_memoryview_copy_contents((__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice))[0]), (__pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice))[0]), __pyx_t_2, __pyx_t_3, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":393
 *         return obj
 * 
 *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice dst_slice
 *         cdef __Pyx_memviewslice src_slice
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":401
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
 *         cdef int array[128]
 *         cdef void *tmp = NULL
 */

static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) {
  int __pyx_v_array[0x80];
  void *__pyx_v_tmp;
  void *__pyx_v_item;
  __Pyx_memviewslice *__pyx_v_dst_slice;
  __Pyx_memviewslice __pyx_v_tmp_slice;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  char const *__pyx_t_5;
  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_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);

  /* "View.MemoryView":403
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
 *         cdef int array[128]
 *         cdef void *tmp = NULL             # <<<<<<<<<<<<<<
 *         cdef void *item
 * 
 */
  __pyx_v_tmp = NULL;

  /* "View.MemoryView":408
 *         cdef __Pyx_memviewslice *dst_slice
 *         cdef __Pyx_memviewslice tmp_slice
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):
 */
  __pyx_v_dst_slice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice));

  /* "View.MemoryView":410
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 */
  __pyx_t_1 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":411
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)             # <<<<<<<<<<<<<<
 *             if tmp == NULL:
 *                 raise MemoryError
 */
    __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);

    /* "View.MemoryView":412
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 *             item = tmp
 */
    __pyx_t_1 = ((__pyx_v_tmp == NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":413
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 *                 raise MemoryError             # <<<<<<<<<<<<<<
 *             item = tmp
 *         else:
 */
      PyErr_NoMemory(); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":412
 *         if <size_t>self.view.itemsize > sizeof(array):
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:             # <<<<<<<<<<<<<<
 *                 raise MemoryError
 *             item = tmp
 */
    }

    /* "View.MemoryView":414
 *             if tmp == NULL:
 *                 raise MemoryError
 *             item = tmp             # <<<<<<<<<<<<<<
 *         else:
 *             item = <void *> array
 */
    __pyx_v_item = __pyx_v_tmp;

    /* "View.MemoryView":410
 *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
 * 
 *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
 *             tmp = PyMem_Malloc(self.view.itemsize)
 *             if tmp == NULL:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":416
 *             item = tmp
 *         else:
 *             item = <void *> array             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  /*else*/ {
    __pyx_v_item = ((void *)__pyx_v_array);
  }
  __pyx_L3:;

  /* "View.MemoryView":418
 *             item = <void *> array
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if self.dtype_is_object:
 *                 (<PyObject **> item)[0] = <PyObject *> value
 */
  /*try:*/ {

    /* "View.MemoryView":419
 * 
 *         try:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 */
    __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":420
 *         try:
 *             if self.dtype_is_object:
 *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
 *             else:
 *                 self.assign_item_from_object(<char *> item, value)
 */
      (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);

      /* "View.MemoryView":419
 * 
 *         try:
 *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 */
      goto __pyx_L8;
    }

    /* "View.MemoryView":422
 *                 (<PyObject **> item)[0] = <PyObject *> value
 *             else:
 *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    /*else*/ {
      __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L8:;

    /* "View.MemoryView":426
 * 
 * 
 *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
 */
    __pyx_t_1 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":427
 * 
 *             if self.view.suboffsets != NULL:
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)             # <<<<<<<<<<<<<<
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
 *                                 item, self.dtype_is_object)
 */
      __pyx_t_2 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "View.MemoryView":426
 * 
 * 
 *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
 */
    }

    /* "View.MemoryView":428
 *             if self.view.suboffsets != NULL:
 *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
 *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,             # <<<<<<<<<<<<<<
 *                                 item, self.dtype_is_object)
 *         finally:
 */
    __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object);
  }

  /* "View.MemoryView":431
 *                                 item, self.dtype_is_object)
 *         finally:
 *             PyMem_Free(tmp)             # <<<<<<<<<<<<<<
 * 
 *     cdef setitem_indexed(self, index, value):
 */
  /*finally:*/ {
    /*normal exit:*/{
      PyMem_Free(__pyx_v_tmp);
      goto __pyx_L7;
    }
    /*exception exit:*/{
      __pyx_L6_error:;
      __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_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __pyx_t_3 = __pyx_lineno; __pyx_t_4 = __pyx_clineno; __pyx_t_5 = __pyx_filename;
      {
        PyMem_Free(__pyx_v_tmp);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __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_lineno = __pyx_t_3; __pyx_clineno = __pyx_t_4; __pyx_filename = __pyx_t_5;
      goto __pyx_L1_error;
    }
    __pyx_L7:;
  }

  /* "View.MemoryView":401
 *                                  src.ndim, dst.ndim, self.dtype_is_object)
 * 
 *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
 *         cdef int array[128]
 *         cdef void *tmp = NULL
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":433
 *             PyMem_Free(tmp)
 * 
 *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)
 */

static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
  char *__pyx_v_itemp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  char *__pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("setitem_indexed", 0);

  /* "View.MemoryView":434
 * 
 *     cdef setitem_indexed(self, index, value):
 *         cdef char *itemp = self.get_item_pointer(index)             # <<<<<<<<<<<<<<
 *         self.assign_item_from_object(itemp, value)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_itemp = __pyx_t_1;

  /* "View.MemoryView":435
 *     cdef setitem_indexed(self, index, value):
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)             # <<<<<<<<<<<<<<
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":433
 *             PyMem_Free(tmp)
 * 
 *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
 *         cdef char *itemp = self.get_item_pointer(index)
 *         self.assign_item_from_object(itemp, value)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":437
 *         self.assign_item_from_object(itemp, value)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
  PyObject *__pyx_v_struct = NULL;
  PyObject *__pyx_v_bytesitem = 0;
  PyObject *__pyx_v_result = 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;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("convert_item_to_object", 0);

  /* "View.MemoryView":440
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 *         import struct             # <<<<<<<<<<<<<<
 *         cdef bytes bytesitem
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_struct = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "View.MemoryView":443
 *         cdef bytes bytesitem
 * 
 *         bytesitem = itemp[:self.view.itemsize]             # <<<<<<<<<<<<<<
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)
 */
  __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":444
 * 
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:             # <<<<<<<<<<<<<<
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    /*try:*/ {

      /* "View.MemoryView":445
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)             # <<<<<<<<<<<<<<
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
      __Pyx_INCREF(__pyx_v_bytesitem);
      __Pyx_GIVEREF(__pyx_v_bytesitem);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_result = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "View.MemoryView":444
 * 
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:             # <<<<<<<<<<<<<<
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 */
    }

    /* "View.MemoryView":449
 *             raise ValueError("Unable to convert item to object")
 *         else:
 *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
 *                 return result[0]
 *             return result
 */
    /*else:*/ {
      __pyx_t_10 = strlen(__pyx_v_self->view.format); 
      __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
      if (__pyx_t_11) {

        /* "View.MemoryView":450
 *         else:
 *             if len(self.view.format) == 1:
 *                 return result[0]             # <<<<<<<<<<<<<<
 *             return result
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;};
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_r = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L6_except_return;

        /* "View.MemoryView":449
 *             raise ValueError("Unable to convert item to object")
 *         else:
 *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
 *                 return result[0]
 *             return result
 */
      }

      /* "View.MemoryView":451
 *             if len(self.view.format) == 1:
 *                 return result[0]
 *             return result             # <<<<<<<<<<<<<<
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_result);
      __pyx_r = __pyx_v_result;
      goto __pyx_L6_except_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "View.MemoryView":446
 *         try:
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:             # <<<<<<<<<<<<<<
 *             raise ValueError("Unable to convert item to object")
 *         else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = PyErr_ExceptionMatches(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_12) {
      __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_9);

      /* "View.MemoryView":447
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
 *         else:
 *             if len(self.view.format) == 1:
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "View.MemoryView":444
 * 
 *         bytesitem = itemp[:self.view.itemsize]
 *         try:             # <<<<<<<<<<<<<<
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 */
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L1_error;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
    goto __pyx_L0;
  }

  /* "View.MemoryView":437
 *         self.assign_item_from_object(itemp, value)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_struct);
  __Pyx_XDECREF(__pyx_v_bytesitem);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":453
 *             return result
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_struct = NULL;
  char __pyx_v_c;
  PyObject *__pyx_v_bytesvalue = 0;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  char *__pyx_t_10;
  char *__pyx_t_11;
  char *__pyx_t_12;
  char *__pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("assign_item_from_object", 0);

  /* "View.MemoryView":456
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 *         import struct             # <<<<<<<<<<<<<<
 *         cdef char c
 *         cdef bytes bytesvalue
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_struct = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "View.MemoryView":461
 *         cdef Py_ssize_t i
 * 
 *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 */
  __pyx_t_2 = PyTuple_Check(__pyx_v_value); 
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "View.MemoryView":462
 * 
 *         if isinstance(value, tuple):
 *             bytesvalue = struct.pack(self.view.format, *value)             # <<<<<<<<<<<<<<
 *         else:
 *             bytesvalue = struct.pack(self.view.format, value)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 462; __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_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 462; __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_6); __pyx_t_6 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "View.MemoryView":461
 *         cdef Py_ssize_t i
 * 
 *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":464
 *             bytesvalue = struct.pack(self.view.format, *value)
 *         else:
 *             bytesvalue = struct.pack(self.view.format, value)             # <<<<<<<<<<<<<<
 * 
 *         for i, c in enumerate(bytesvalue):
 */
  /*else*/ {
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
    __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":466
 *             bytesvalue = struct.pack(self.view.format, value)
 * 
 *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
 *             itemp[i] = c
 * 
 */
  __pyx_t_7 = 0;
  if (unlikely(__pyx_v_bytesvalue == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_INCREF(__pyx_v_bytesvalue);
  __pyx_t_9 = __pyx_v_bytesvalue;
  __pyx_t_11 = PyBytes_AS_STRING(__pyx_t_9);
  __pyx_t_12 = (__pyx_t_11 + PyBytes_GET_SIZE(__pyx_t_9));
  for (__pyx_t_13 = __pyx_t_11; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) {
    __pyx_t_10 = __pyx_t_13;
    __pyx_v_c = (__pyx_t_10[0]);

    /* "View.MemoryView":467
 * 
 *         for i, c in enumerate(bytesvalue):
 *             itemp[i] = c             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
    __pyx_v_i = __pyx_t_7;

    /* "View.MemoryView":466
 *             bytesvalue = struct.pack(self.view.format, value)
 * 
 *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
 *             itemp[i] = c
 * 
 */
    __pyx_t_7 = (__pyx_t_7 + 1);

    /* "View.MemoryView":467
 * 
 *         for i, c in enumerate(bytesvalue):
 *             itemp[i] = c             # <<<<<<<<<<<<<<
 * 
 *     @cname('getbuffer')
 */
    (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "View.MemoryView":453
 *             return result
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         """Only used if instantiated manually by the user, or if Cython doesn't
 *         know how to convert the type"""
 */

  /* function exit code */
  __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_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_struct);
  __Pyx_XDECREF(__pyx_v_bytesvalue);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":470
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_memoryview_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_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  Py_ssize_t *__pyx_t_2;
  char *__pyx_t_3;
  void *__pyx_t_4;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  __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);
  }

  /* "View.MemoryView":471
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.shape = self.view.shape
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":472
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape             # <<<<<<<<<<<<<<
 *         else:
 *             info.shape = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.shape;
    __pyx_v_info->shape = __pyx_t_2;

    /* "View.MemoryView":471
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.shape = self.view.shape
 *         else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":474
 *             info.shape = self.view.shape
 *         else:
 *             info.shape = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_STRIDES:
 */
  /*else*/ {
    __pyx_v_info->shape = NULL;
  }
  __pyx_L3:;

  /* "View.MemoryView":476
 *             info.shape = NULL
 * 
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.strides = self.view.strides
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":477
 * 
 *         if flags & PyBUF_STRIDES:
 *             info.strides = self.view.strides             # <<<<<<<<<<<<<<
 *         else:
 *             info.strides = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.strides;
    __pyx_v_info->strides = __pyx_t_2;

    /* "View.MemoryView":476
 *             info.shape = NULL
 * 
 *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
 *             info.strides = self.view.strides
 *         else:
 */
    goto __pyx_L4;
  }

  /* "View.MemoryView":479
 *             info.strides = self.view.strides
 *         else:
 *             info.strides = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_INDIRECT:
 */
  /*else*/ {
    __pyx_v_info->strides = NULL;
  }
  __pyx_L4:;

  /* "View.MemoryView":481
 *             info.strides = NULL
 * 
 *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
 *             info.suboffsets = self.view.suboffsets
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":482
 * 
 *         if flags & PyBUF_INDIRECT:
 *             info.suboffsets = self.view.suboffsets             # <<<<<<<<<<<<<<
 *         else:
 *             info.suboffsets = NULL
 */
    __pyx_t_2 = __pyx_v_self->view.suboffsets;
    __pyx_v_info->suboffsets = __pyx_t_2;

    /* "View.MemoryView":481
 *             info.strides = NULL
 * 
 *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
 *             info.suboffsets = self.view.suboffsets
 *         else:
 */
    goto __pyx_L5;
  }

  /* "View.MemoryView":484
 *             info.suboffsets = self.view.suboffsets
 *         else:
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 * 
 *         if flags & PyBUF_FORMAT:
 */
  /*else*/ {
    __pyx_v_info->suboffsets = NULL;
  }
  __pyx_L5:;

  /* "View.MemoryView":486
 *             info.suboffsets = NULL
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.view.format
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":487
 * 
 *         if flags & PyBUF_FORMAT:
 *             info.format = self.view.format             # <<<<<<<<<<<<<<
 *         else:
 *             info.format = NULL
 */
    __pyx_t_3 = __pyx_v_self->view.format;
    __pyx_v_info->format = __pyx_t_3;

    /* "View.MemoryView":486
 *             info.suboffsets = NULL
 * 
 *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
 *             info.format = self.view.format
 *         else:
 */
    goto __pyx_L6;
  }

  /* "View.MemoryView":489
 *             info.format = self.view.format
 *         else:
 *             info.format = NULL             # <<<<<<<<<<<<<<
 * 
 *         info.buf = self.view.buf
 */
  /*else*/ {
    __pyx_v_info->format = NULL;
  }
  __pyx_L6:;

  /* "View.MemoryView":491
 *             info.format = NULL
 * 
 *         info.buf = self.view.buf             # <<<<<<<<<<<<<<
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize
 */
  __pyx_t_4 = __pyx_v_self->view.buf;
  __pyx_v_info->buf = __pyx_t_4;

  /* "View.MemoryView":492
 * 
 *         info.buf = self.view.buf
 *         info.ndim = self.view.ndim             # <<<<<<<<<<<<<<
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len
 */
  __pyx_t_5 = __pyx_v_self->view.ndim;
  __pyx_v_info->ndim = __pyx_t_5;

  /* "View.MemoryView":493
 *         info.buf = self.view.buf
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize             # <<<<<<<<<<<<<<
 *         info.len = self.view.len
 *         info.readonly = 0
 */
  __pyx_t_6 = __pyx_v_self->view.itemsize;
  __pyx_v_info->itemsize = __pyx_t_6;

  /* "View.MemoryView":494
 *         info.ndim = self.view.ndim
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len             # <<<<<<<<<<<<<<
 *         info.readonly = 0
 *         info.obj = self
 */
  __pyx_t_6 = __pyx_v_self->view.len;
  __pyx_v_info->len = __pyx_t_6;

  /* "View.MemoryView":495
 *         info.itemsize = self.view.itemsize
 *         info.len = self.view.len
 *         info.readonly = 0             # <<<<<<<<<<<<<<
 *         info.obj = self
 * 
 */
  __pyx_v_info->readonly = 0;

  /* "View.MemoryView":496
 *         info.len = self.view.len
 *         info.readonly = 0
 *         info.obj = self             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
 */
  __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);

  /* "View.MemoryView":470
 * 
 *     @cname('getbuffer')
 *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
 *         if flags & PyBUF_STRIDES:
 *             info.shape = self.view.shape
 */

  /* function exit code */
  __pyx_r = 0;
  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_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":503
 *     property T:
 *         @cname('__pyx_memoryview_transpose')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _memoryviewslice result = memoryview_copy(self)
 *             transpose_memslice(&result.from_slice)
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":504
 *         @cname('__pyx_memoryview_transpose')
 *         def __get__(self):
 *             cdef _memoryviewslice result = memoryview_copy(self)             # <<<<<<<<<<<<<<
 *             transpose_memslice(&result.from_slice)
 *             return result
 */
  __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 504; __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_memoryviewslice_type))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":505
 *         def __get__(self):
 *             cdef _memoryviewslice result = memoryview_copy(self)
 *             transpose_memslice(&result.from_slice)             # <<<<<<<<<<<<<<
 *             return result
 * 
 */
  __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":506
 *             cdef _memoryviewslice result = memoryview_copy(self)
 *             transpose_memslice(&result.from_slice)
 *             return result             # <<<<<<<<<<<<<<
 * 
 *     property base:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":503
 *     property T:
 *         @cname('__pyx_memoryview_transpose')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             cdef _memoryviewslice result = memoryview_copy(self)
 *             transpose_memslice(&result.from_slice)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":510
 *     property base:
 *         @cname('__pyx_memoryview__get__base')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.obj
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":511
 *         @cname('__pyx_memoryview__get__base')
 *         def __get__(self):
 *             return self.obj             # <<<<<<<<<<<<<<
 * 
 *     property shape:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->obj);
  __pyx_r = __pyx_v_self->obj;
  goto __pyx_L0;

  /* "View.MemoryView":510
 *     property base:
 *         @cname('__pyx_memoryview__get__base')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.obj
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":515
 *     property shape:
 *         @cname('__pyx_memoryview_get_shape')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return tuple([length for length in self.view.shape[:self.view.ndim]])
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_v_length;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t *__pyx_t_2;
  Py_ssize_t *__pyx_t_3;
  Py_ssize_t *__pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":516
 *         @cname('__pyx_memoryview_get_shape')
 *         def __get__(self):
 *             return tuple([length for length in self.view.shape[:self.view.ndim]])             # <<<<<<<<<<<<<<
 * 
 *     property strides:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
  for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
    __pyx_t_2 = __pyx_t_4;
    __pyx_v_length = (__pyx_t_2[0]);
    __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":515
 *     property shape:
 *         @cname('__pyx_memoryview_get_shape')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return tuple([length for length in self.view.shape[:self.view.ndim]])
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":520
 *     property strides:
 *         @cname('__pyx_memoryview_get_strides')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.view.strides == NULL:
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_v_stride;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t *__pyx_t_3;
  Py_ssize_t *__pyx_t_4;
  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("__get__", 0);

  /* "View.MemoryView":521
 *         @cname('__pyx_memoryview_get_strides')
 *         def __get__(self):
 *             if self.view.strides == NULL:             # <<<<<<<<<<<<<<
 * 
 *                 raise ValueError("Buffer view does not expose strides")
 */
  __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":523
 *             if self.view.strides == NULL:
 * 
 *                 raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
 * 
 *             return tuple([stride for stride in self.view.strides[:self.view.ndim]])
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":521
 *         @cname('__pyx_memoryview_get_strides')
 *         def __get__(self):
 *             if self.view.strides == NULL:             # <<<<<<<<<<<<<<
 * 
 *                 raise ValueError("Buffer view does not expose strides")
 */
  }

  /* "View.MemoryView":525
 *                 raise ValueError("Buffer view does not expose strides")
 * 
 *             return tuple([stride for stride in self.view.strides[:self.view.ndim]])             # <<<<<<<<<<<<<<
 * 
 *     property suboffsets:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
  for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
    __pyx_t_3 = __pyx_t_5;
    __pyx_v_stride = (__pyx_t_3[0]);
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":520
 *     property strides:
 *         @cname('__pyx_memoryview_get_strides')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.view.strides == NULL:
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":529
 *     property suboffsets:
 *         @cname('__pyx_memoryview_get_suboffsets')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.view.suboffsets == NULL:
 *                 return (-1,) * self.view.ndim
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_v_suboffset;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t *__pyx_t_4;
  Py_ssize_t *__pyx_t_5;
  Py_ssize_t *__pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":530
 *         @cname('__pyx_memoryview_get_suboffsets')
 *         def __get__(self):
 *             if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
 *                 return (-1,) * self.view.ndim
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":531
 *         def __get__(self):
 *             if self.view.suboffsets == NULL:
 *                 return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
 * 
 *             return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__67, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":530
 *         @cname('__pyx_memoryview_get_suboffsets')
 *         def __get__(self):
 *             if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
 *                 return (-1,) * self.view.ndim
 * 
 */
  }

  /* "View.MemoryView":533
 *                 return (-1,) * self.view.ndim
 * 
 *             return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])             # <<<<<<<<<<<<<<
 * 
 *     property ndim:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
  for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
    __pyx_t_4 = __pyx_t_6;
    __pyx_v_suboffset = (__pyx_t_4[0]);
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":529
 *     property suboffsets:
 *         @cname('__pyx_memoryview_get_suboffsets')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self.view.suboffsets == NULL:
 *                 return (-1,) * self.view.ndim
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":537
 *     property ndim:
 *         @cname('__pyx_memoryview_get_ndim')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.view.ndim
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__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);

  /* "View.MemoryView":538
 *         @cname('__pyx_memoryview_get_ndim')
 *         def __get__(self):
 *             return self.view.ndim             # <<<<<<<<<<<<<<
 * 
 *     property itemsize:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":537
 *     property ndim:
 *         @cname('__pyx_memoryview_get_ndim')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.view.ndim
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":542
 *     property itemsize:
 *         @cname('__pyx_memoryview_get_itemsize')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.view.itemsize
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__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);

  /* "View.MemoryView":543
 *         @cname('__pyx_memoryview_get_itemsize')
 *         def __get__(self):
 *             return self.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     property nbytes:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":542
 *     property itemsize:
 *         @cname('__pyx_memoryview_get_itemsize')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.view.itemsize
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":547
 *     property nbytes:
 *         @cname('__pyx_memoryview_get_nbytes')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.size * self.view.itemsize
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__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("__get__", 0);

  /* "View.MemoryView":548
 *         @cname('__pyx_memoryview_get_nbytes')
 *         def __get__(self):
 *             return self.size * self.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     property size:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 548; __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_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":547
 *     property nbytes:
 *         @cname('__pyx_memoryview_get_nbytes')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.size * self.view.itemsize
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":552
 *     property size:
 *         @cname('__pyx_memoryview_get_size')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._size is None:
 *                 result = 1
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t *__pyx_t_3;
  Py_ssize_t *__pyx_t_4;
  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("__get__", 0);

  /* "View.MemoryView":553
 *         @cname('__pyx_memoryview_get_size')
 *         def __get__(self):
 *             if self._size is None:             # <<<<<<<<<<<<<<
 *                 result = 1
 * 
 */
  __pyx_t_1 = (__pyx_v_self->_size == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":554
 *         def __get__(self):
 *             if self._size is None:
 *                 result = 1             # <<<<<<<<<<<<<<
 * 
 *                 for length in self.view.shape[:self.view.ndim]:
 */
    __Pyx_INCREF(__pyx_int_1);
    __pyx_v_result = __pyx_int_1;

    /* "View.MemoryView":556
 *                 result = 1
 * 
 *                 for length in self.view.shape[:self.view.ndim]:             # <<<<<<<<<<<<<<
 *                     result *= length
 * 
 */
    __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
    for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
      __pyx_t_3 = __pyx_t_5;
      __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "View.MemoryView":557
 * 
 *                 for length in self.view.shape[:self.view.ndim]:
 *                     result *= length             # <<<<<<<<<<<<<<
 * 
 *                 self._size = result
 */
      __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
      __pyx_t_6 = 0;
    }

    /* "View.MemoryView":559
 *                     result *= length
 * 
 *                 self._size = result             # <<<<<<<<<<<<<<
 * 
 *             return self._size
 */
    __Pyx_INCREF(__pyx_v_result);
    __Pyx_GIVEREF(__pyx_v_result);
    __Pyx_GOTREF(__pyx_v_self->_size);
    __Pyx_DECREF(__pyx_v_self->_size);
    __pyx_v_self->_size = __pyx_v_result;

    /* "View.MemoryView":553
 *         @cname('__pyx_memoryview_get_size')
 *         def __get__(self):
 *             if self._size is None:             # <<<<<<<<<<<<<<
 *                 result = 1
 * 
 */
  }

  /* "View.MemoryView":561
 *                 self._size = result
 * 
 *             return self._size             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_size);
  __pyx_r = __pyx_v_self->_size;
  goto __pyx_L0;

  /* "View.MemoryView":552
 *     property size:
 *         @cname('__pyx_memoryview_get_size')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             if self._size is None:
 *                 result = 1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":563
 *             return self._size
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]
 */

/* Python wrapper */
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__len__", 0);

  /* "View.MemoryView":564
 * 
 *     def __len__(self):
 *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
 *             return self.view.shape[0]
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":565
 *     def __len__(self):
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]             # <<<<<<<<<<<<<<
 * 
 *         return 0
 */
    __pyx_r = (__pyx_v_self->view.shape[0]);
    goto __pyx_L0;

    /* "View.MemoryView":564
 * 
 *     def __len__(self):
 *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
 *             return self.view.shape[0]
 * 
 */
  }

  /* "View.MemoryView":567
 *             return self.view.shape[0]
 * 
 *         return 0             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":563
 *             return self._size
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         if self.view.ndim >= 1:
 *             return self.view.shape[0]
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":569
 *         return 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__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("__repr__", 0);

  /* "View.MemoryView":570
 * 
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
 *                                                id(self))
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 570; __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_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":571
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "View.MemoryView":570
 * 
 *     def __repr__(self):
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
 *                                                id(self))
 * 
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":569
 *         return 0
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
 *                                                id(self))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":573
 *                                                id(self))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__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("__str__", 0);

  /* "View.MemoryView":574
 * 
 *     def __str__(self):
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 574; __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_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 574; __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[4]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":573
 *                                                id(self))
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":577
 * 
 * 
 *     def is_c_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice *__pyx_v_mslice;
  __Pyx_memviewslice __pyx_v_tmp;
  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("is_c_contig", 0);

  /* "View.MemoryView":580
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
 *         return slice_is_contig(mslice, 'C', self.view.ndim)
 * 
 */
  __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));

  /* "View.MemoryView":581
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)
 *         return slice_is_contig(mslice, 'C', self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *     def is_f_contig(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig(__pyx_v_mslice, 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":577
 * 
 * 
 *     def is_c_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":583
 *         return slice_is_contig(mslice, 'C', self.view.ndim)
 * 
 *     def is_f_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice *__pyx_v_mslice;
  __Pyx_memviewslice __pyx_v_tmp;
  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("is_f_contig", 0);

  /* "View.MemoryView":586
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
 *         return slice_is_contig(mslice, 'F', self.view.ndim)
 * 
 */
  __pyx_v_mslice = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp));

  /* "View.MemoryView":587
 *         cdef __Pyx_memviewslice tmp
 *         mslice = get_slice_from_memview(self, &tmp)
 *         return slice_is_contig(mslice, 'F', self.view.ndim)             # <<<<<<<<<<<<<<
 * 
 *     def copy(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig(__pyx_v_mslice, 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":583
 *         return slice_is_contig(mslice, 'C', self.view.ndim)
 * 
 *     def is_f_contig(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice *mslice
 *         cdef __Pyx_memviewslice tmp
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":589
 *         return slice_is_contig(mslice, 'F', self.view.ndim)
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice __pyx_v_mslice;
  int __pyx_v_flags;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_memviewslice __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copy", 0);

  /* "View.MemoryView":591
 *     def copy(self):
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS             # <<<<<<<<<<<<<<
 * 
 *         slice_copy(self, &mslice)
 */
  __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));

  /* "View.MemoryView":593
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 * 
 *         slice_copy(self, &mslice)             # <<<<<<<<<<<<<<
 *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
 *                                    self.view.itemsize,
 */
  __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));

  /* "View.MemoryView":594
 * 
 *         slice_copy(self, &mslice)
 *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,             # <<<<<<<<<<<<<<
 *                                    self.view.itemsize,
 *                                    flags|PyBUF_C_CONTIGUOUS,
 */
  __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), __pyx_k_c, __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_mslice = __pyx_t_1;

  /* "View.MemoryView":599
 *                                    self.dtype_is_object)
 * 
 *         return memoryview_copy_from_slice(self, &mslice)             # <<<<<<<<<<<<<<
 * 
 *     def copy_fortran(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":589
 *         return slice_is_contig(mslice, 'F', self.view.ndim)
 * 
 *     def copy(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice mslice
 *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":601
 *         return memoryview_copy_from_slice(self, &mslice)
 * 
 *     def copy_fortran(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 */

/* Python wrapper */
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
  __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
  __Pyx_memviewslice __pyx_v_src;
  __Pyx_memviewslice __pyx_v_dst;
  int __pyx_v_flags;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_memviewslice __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("copy_fortran", 0);

  /* "View.MemoryView":603
 *     def copy_fortran(self):
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS             # <<<<<<<<<<<<<<
 * 
 *         slice_copy(self, &src)
 */
  __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));

  /* "View.MemoryView":605
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 * 
 *         slice_copy(self, &src)             # <<<<<<<<<<<<<<
 *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,
 *                                 self.view.itemsize,
 */
  __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));

  /* "View.MemoryView":606
 * 
 *         slice_copy(self, &src)
 *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,             # <<<<<<<<<<<<<<
 *                                 self.view.itemsize,
 *                                 flags|PyBUF_F_CONTIGUOUS,
 */
  __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), __pyx_k_fortran, __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_dst = __pyx_t_1;

  /* "View.MemoryView":611
 *                                 self.dtype_is_object)
 * 
 *         return memoryview_copy_from_slice(self, &dst)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":601
 *         return memoryview_copy_from_slice(self, &mslice)
 * 
 *     def copy_fortran(self):             # <<<<<<<<<<<<<<
 *         cdef __Pyx_memviewslice src, dst
 *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":615
 * 
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 */

static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
  struct __pyx_memoryview_obj *__pyx_v_result = 0;
  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("memoryview_cwrapper", 0);

  /* "View.MemoryView":616
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)             # <<<<<<<<<<<<<<
 *     result.typeinfo = typeinfo
 *     return result
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 616; __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[4]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "View.MemoryView":617
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_v_result->typeinfo = __pyx_v_typeinfo;

  /* "View.MemoryView":618
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 *     return result             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_check')
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":615
 * 
 * @cname('__pyx_memoryview_new')
 * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
 *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
 *     result.typeinfo = typeinfo
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":621
 * 
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
 *     return isinstance(o, memoryview)
 * 
 */

static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("memoryview_check", 0);

  /* "View.MemoryView":622
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):
 *     return isinstance(o, memoryview)             # <<<<<<<<<<<<<<
 * 
 * cdef tuple _unellipsify(object index, int ndim):
 */
  __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type); 
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "View.MemoryView":621
 * 
 * @cname('__pyx_memoryview_check')
 * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
 *     return isinstance(o, memoryview)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":624
 *     return isinstance(o, memoryview)
 * 
 * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
 *     """
 *     Replace all ellipses with full slices and fill incomplete indices with
 */

static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
  PyObject *__pyx_v_tup = NULL;
  PyObject *__pyx_v_result = NULL;
  int __pyx_v_have_slices;
  int __pyx_v_seen_ellipsis;
  CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_item = NULL;
  Py_ssize_t __pyx_v_nslices;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  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;
  Py_ssize_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_unellipsify", 0);

  /* "View.MemoryView":629
 *     full slices.
 *     """
 *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
 *         tup = (index,)
 *     else:
 */
  __pyx_t_1 = PyTuple_Check(__pyx_v_index); 
  __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":630
 *     """
 *     if not isinstance(index, tuple):
 *         tup = (index,)             # <<<<<<<<<<<<<<
 *     else:
 *         tup = index
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_index);
    __Pyx_GIVEREF(__pyx_v_index);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
    __pyx_v_tup = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "View.MemoryView":629
 *     full slices.
 *     """
 *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
 *         tup = (index,)
 *     else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":632
 *         tup = (index,)
 *     else:
 *         tup = index             # <<<<<<<<<<<<<<
 * 
 *     result = []
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_index);
    __pyx_v_tup = __pyx_v_index;
  }
  __pyx_L3:;

  /* "View.MemoryView":634
 *         tup = index
 * 
 *     result = []             # <<<<<<<<<<<<<<
 *     have_slices = False
 *     seen_ellipsis = False
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_result = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "View.MemoryView":635
 * 
 *     result = []
 *     have_slices = False             # <<<<<<<<<<<<<<
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 */
  __pyx_v_have_slices = 0;

  /* "View.MemoryView":636
 *     result = []
 *     have_slices = False
 *     seen_ellipsis = False             # <<<<<<<<<<<<<<
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 */
  __pyx_v_seen_ellipsis = 0;

  /* "View.MemoryView":637
 *     have_slices = False
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
    __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
    __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "View.MemoryView":638
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:             # <<<<<<<<<<<<<<
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 */
    __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":639
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 *                 seen_ellipsis = True
 */
      __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
      if (__pyx_t_1) {

        /* "View.MemoryView":640
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
 *                 seen_ellipsis = True
 *             else:
 */
        __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        { Py_ssize_t __pyx_temp;
          for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
            __Pyx_INCREF(__pyx_slice__68);
            __Pyx_GIVEREF(__pyx_slice__68);
            PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__68);
          }
        }
        __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "View.MemoryView":641
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 *                 seen_ellipsis = True             # <<<<<<<<<<<<<<
 *             else:
 *                 result.append(slice(None))
 */
        __pyx_v_seen_ellipsis = 1;

        /* "View.MemoryView":639
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:
 *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 *                 seen_ellipsis = True
 */
        goto __pyx_L7;
      }

      /* "View.MemoryView":643
 *                 seen_ellipsis = True
 *             else:
 *                 result.append(slice(None))             # <<<<<<<<<<<<<<
 *             have_slices = True
 *         else:
 */
      /*else*/ {
        __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__69); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L7:;

      /* "View.MemoryView":644
 *             else:
 *                 result.append(slice(None))
 *             have_slices = True             # <<<<<<<<<<<<<<
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):
 */
      __pyx_v_have_slices = 1;

      /* "View.MemoryView":638
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):
 *         if item is Ellipsis:             # <<<<<<<<<<<<<<
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
 */
      goto __pyx_L6;
    }

    /* "View.MemoryView":646
 *             have_slices = True
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
 *                 raise TypeError("Cannot index with type '%s'" % type(item))
 * 
 */
    /*else*/ {
      __pyx_t_2 = PySlice_Check(__pyx_v_item); 
      __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
      if (__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
      __pyx_t_1 = __pyx_t_10;
      __pyx_L9_bool_binop_done:;
      if (__pyx_t_1) {

        /* "View.MemoryView":647
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):
 *                 raise TypeError("Cannot index with type '%s'" % type(item))             # <<<<<<<<<<<<<<
 * 
 *             have_slices = have_slices or isinstance(item, slice)
 */
        __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        {__pyx_filename = __pyx_f[4]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "View.MemoryView":646
 *             have_slices = True
 *         else:
 *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
 *                 raise TypeError("Cannot index with type '%s'" % type(item))
 * 
 */
      }

      /* "View.MemoryView":649
 *                 raise TypeError("Cannot index with type '%s'" % type(item))
 * 
 *             have_slices = have_slices or isinstance(item, slice)             # <<<<<<<<<<<<<<
 *             result.append(item)
 * 
 */
      __pyx_t_10 = (__pyx_v_have_slices != 0);
      if (!__pyx_t_10) {
      } else {
        __pyx_t_1 = __pyx_t_10;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_10 = PySlice_Check(__pyx_v_item); 
      __pyx_t_2 = (__pyx_t_10 != 0);
      __pyx_t_1 = __pyx_t_2;
      __pyx_L11_bool_binop_done:;
      __pyx_v_have_slices = __pyx_t_1;

      /* "View.MemoryView":650
 * 
 *             have_slices = have_slices or isinstance(item, slice)
 *             result.append(item)             # <<<<<<<<<<<<<<
 * 
 *     nslices = ndim - len(result)
 */
      __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L6:;

    /* "View.MemoryView":637
 *     have_slices = False
 *     seen_ellipsis = False
 *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "View.MemoryView":652
 *             result.append(item)
 * 
 *     nslices = ndim - len(result)             # <<<<<<<<<<<<<<
 *     if nslices:
 *         result.extend([slice(None)] * nslices)
 */
  __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);

  /* "View.MemoryView":653
 * 
 *     nslices = ndim - len(result)
 *     if nslices:             # <<<<<<<<<<<<<<
 *         result.extend([slice(None)] * nslices)
 * 
 */
  __pyx_t_1 = (__pyx_v_nslices != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":654
 *     nslices = ndim - len(result)
 *     if nslices:
 *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
 * 
 *     return have_slices or nslices, tuple(result)
 */
    __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    { Py_ssize_t __pyx_temp;
      for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
        __Pyx_INCREF(__pyx_slice__70);
        __Pyx_GIVEREF(__pyx_slice__70);
        PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__70);
      }
    }
    __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "View.MemoryView":653
 * 
 *     nslices = ndim - len(result)
 *     if nslices:             # <<<<<<<<<<<<<<
 *         result.extend([slice(None)] * nslices)
 * 
 */
  }

  /* "View.MemoryView":656
 *         result.extend([slice(None)] * nslices)
 * 
 *     return have_slices or nslices, tuple(result)             # <<<<<<<<<<<<<<
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 */
  __Pyx_XDECREF(__pyx_r);
  if (!__pyx_v_have_slices) {
  } else {
    __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L14_bool_binop_done;
  }
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_L14_bool_binop_done:;
  __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":624
 *     return isinstance(o, memoryview)
 * 
 * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
 *     """
 *     Replace all ellipses with full slices and fill incomplete indices with
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_tup);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":658
 *     return have_slices or nslices, tuple(result)
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 */

static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
  Py_ssize_t __pyx_v_suboffset;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t *__pyx_t_1;
  Py_ssize_t *__pyx_t_2;
  Py_ssize_t *__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("assert_direct_dimensions", 0);

  /* "View.MemoryView":659
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 *     for suboffset in suboffsets[:ndim]:             # <<<<<<<<<<<<<<
 *         if suboffset >= 0:
 *             raise ValueError("Indirect dimensions not supported")
 */
  __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
  for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
    __pyx_t_1 = __pyx_t_3;
    __pyx_v_suboffset = (__pyx_t_1[0]);

    /* "View.MemoryView":660
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Indirect dimensions not supported")
 * 
 */
    __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
    if (__pyx_t_4) {

      /* "View.MemoryView":661
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 661; __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[4]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":660
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("Indirect dimensions not supported")
 * 
 */
    }
  }

  /* "View.MemoryView":658
 *     return have_slices or nslices, tuple(result)
 * 
 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":668
 * 
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim
 *     cdef bint negative_step
 */

static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
  int __pyx_v_new_ndim;
  int __pyx_v_suboffset_dim;
  int __pyx_v_dim;
  __Pyx_memviewslice __pyx_v_src;
  __Pyx_memviewslice __pyx_v_dst;
  __Pyx_memviewslice *__pyx_v_p_src;
  struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
  __Pyx_memviewslice *__pyx_v_p_dst;
  int *__pyx_v_p_suboffset_dim;
  Py_ssize_t __pyx_v_start;
  Py_ssize_t __pyx_v_stop;
  Py_ssize_t __pyx_v_step;
  int __pyx_v_have_start;
  int __pyx_v_have_stop;
  int __pyx_v_have_step;
  PyObject *__pyx_v_index = NULL;
  struct __pyx_memoryview_obj *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  struct __pyx_memoryview_obj *__pyx_t_4;
  char *__pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  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("memview_slice", 0);

  /* "View.MemoryView":669
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim             # <<<<<<<<<<<<<<
 *     cdef bint negative_step
 *     cdef __Pyx_memviewslice src, dst
 */
  __pyx_v_new_ndim = 0;
  __pyx_v_suboffset_dim = -1;

  /* "View.MemoryView":676
 * 
 * 
 *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
 * 
 *     cdef _memoryviewslice memviewsliceobj
 */
  memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst)));

  /* "View.MemoryView":680
 *     cdef _memoryviewslice memviewsliceobj
 * 
 *     assert memview.view.ndim > 0             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(memview, _memoryviewslice):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif

  /* "View.MemoryView":682
 *     assert memview.view.ndim > 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":683
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         memviewsliceobj = memview             # <<<<<<<<<<<<<<
 *         p_src = &memviewsliceobj.from_slice
 *     else:
 */
    if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((PyObject *)__pyx_v_memview);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "View.MemoryView":684
 *     if isinstance(memview, _memoryviewslice):
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice             # <<<<<<<<<<<<<<
 *     else:
 *         slice_copy(memview, &src)
 */
    __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);

    /* "View.MemoryView":682
 *     assert memview.view.ndim > 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         memviewsliceobj = memview
 *         p_src = &memviewsliceobj.from_slice
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":686
 *         p_src = &memviewsliceobj.from_slice
 *     else:
 *         slice_copy(memview, &src)             # <<<<<<<<<<<<<<
 *         p_src = &src
 * 
 */
  /*else*/ {
    __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));

    /* "View.MemoryView":687
 *     else:
 *         slice_copy(memview, &src)
 *         p_src = &src             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_p_src = (&__pyx_v_src);
  }
  __pyx_L3:;

  /* "View.MemoryView":693
 * 
 * 
 *     dst.memview = p_src.memview             # <<<<<<<<<<<<<<
 *     dst.data = p_src.data
 * 
 */
  __pyx_t_4 = __pyx_v_p_src->memview;
  __pyx_v_dst.memview = __pyx_t_4;

  /* "View.MemoryView":694
 * 
 *     dst.memview = p_src.memview
 *     dst.data = p_src.data             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __pyx_v_p_src->data;
  __pyx_v_dst.data = __pyx_t_5;

  /* "View.MemoryView":699
 * 
 * 
 *     cdef __Pyx_memviewslice *p_dst = &dst             # <<<<<<<<<<<<<<
 *     cdef int *p_suboffset_dim = &suboffset_dim
 *     cdef Py_ssize_t start, stop, step
 */
  __pyx_v_p_dst = (&__pyx_v_dst);

  /* "View.MemoryView":700
 * 
 *     cdef __Pyx_memviewslice *p_dst = &dst
 *     cdef int *p_suboffset_dim = &suboffset_dim             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t start, stop, step
 *     cdef bint have_start, have_stop, have_step
 */
  __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);

  /* "View.MemoryView":704
 *     cdef bint have_start, have_stop, have_step
 * 
 *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
 *         if PyIndex_Check(index):
 *             slice_memviewslice(
 */
  __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
    __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        #endif
      }
    } else {
      __pyx_t_9 = __pyx_t_8(__pyx_t_3);
      if (unlikely(!__pyx_t_9)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_9);
    }
    __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_v_dim = __pyx_t_6;
    __pyx_t_6 = (__pyx_t_6 + 1);

    /* "View.MemoryView":705
 * 
 *     for dim, index in enumerate(indices):
 *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
 *             slice_memviewslice(
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 */
    __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":709
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 *                 index, 0, 0, # start, stop, step             # <<<<<<<<<<<<<<
 *                 0, 0, 0, # have_{start,stop,step}
 *                 False)
 */
      __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":706
 *     for dim, index in enumerate(indices):
 *         if PyIndex_Check(index):
 *             slice_memviewslice(             # <<<<<<<<<<<<<<
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 */
      __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":705
 * 
 *     for dim, index in enumerate(indices):
 *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
 *             slice_memviewslice(
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 */
      goto __pyx_L6;
    }

    /* "View.MemoryView":712
 *                 0, 0, 0, # have_{start,stop,step}
 *                 False)
 *         elif index is None:             # <<<<<<<<<<<<<<
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0
 */
    __pyx_t_2 = (__pyx_v_index == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":713
 *                 False)
 *         elif index is None:
 *             p_dst.shape[new_ndim] = 1             # <<<<<<<<<<<<<<
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1
 */
      (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;

      /* "View.MemoryView":714
 *         elif index is None:
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0             # <<<<<<<<<<<<<<
 *             p_dst.suboffsets[new_ndim] = -1
 *             new_ndim += 1
 */
      (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;

      /* "View.MemoryView":715
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1             # <<<<<<<<<<<<<<
 *             new_ndim += 1
 *         else:
 */
      (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;

      /* "View.MemoryView":716
 *             p_dst.strides[new_ndim] = 0
 *             p_dst.suboffsets[new_ndim] = -1
 *             new_ndim += 1             # <<<<<<<<<<<<<<
 *         else:
 *             start = index.start or 0
 */
      __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);

      /* "View.MemoryView":712
 *                 0, 0, 0, # have_{start,stop,step}
 *                 False)
 *         elif index is None:             # <<<<<<<<<<<<<<
 *             p_dst.shape[new_ndim] = 1
 *             p_dst.strides[new_ndim] = 0
 */
      goto __pyx_L6;
    }

    /* "View.MemoryView":718
 *             new_ndim += 1
 *         else:
 *             start = index.start or 0             # <<<<<<<<<<<<<<
 *             stop = index.stop or 0
 *             step = index.step or 0
 */
    /*else*/ {
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L7_bool_binop_done:;
      __pyx_v_start = __pyx_t_10;

      /* "View.MemoryView":719
 *         else:
 *             start = index.start or 0
 *             stop = index.stop or 0             # <<<<<<<<<<<<<<
 *             step = index.step or 0
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L9_bool_binop_done:;
      __pyx_v_stop = __pyx_t_10;

      /* "View.MemoryView":720
 *             start = index.start or 0
 *             stop = index.stop or 0
 *             step = index.step or 0             # <<<<<<<<<<<<<<
 * 
 *             have_start = index.start is not None
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = __pyx_t_12;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_10 = 0;
      __pyx_L11_bool_binop_done:;
      __pyx_v_step = __pyx_t_10;

      /* "View.MemoryView":722
 *             step = index.step or 0
 * 
 *             have_start = index.start is not None             # <<<<<<<<<<<<<<
 *             have_stop = index.stop is not None
 *             have_step = index.step is not None
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_start = __pyx_t_1;

      /* "View.MemoryView":723
 * 
 *             have_start = index.start is not None
 *             have_stop = index.stop is not None             # <<<<<<<<<<<<<<
 *             have_step = index.step is not None
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_stop = __pyx_t_1;

      /* "View.MemoryView":724
 *             have_start = index.start is not None
 *             have_stop = index.stop is not None
 *             have_step = index.step is not None             # <<<<<<<<<<<<<<
 * 
 *             slice_memviewslice(
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = (__pyx_t_9 != Py_None);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_have_step = __pyx_t_1;

      /* "View.MemoryView":726
 *             have_step = index.step is not None
 * 
 *             slice_memviewslice(             # <<<<<<<<<<<<<<
 *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
 *                 dim, new_ndim, p_suboffset_dim,
 */
      __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":732
 *                 have_start, have_stop, have_step,
 *                 True)
 *             new_ndim += 1             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(memview, _memoryviewslice):
 */
      __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
    }
    __pyx_L6:;

    /* "View.MemoryView":704
 *     cdef bint have_start, have_stop, have_step
 * 
 *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
 *         if PyIndex_Check(index):
 *             slice_memviewslice(
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "View.MemoryView":734
 *             new_ndim += 1
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":735
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "View.MemoryView":736
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_dtype_func,
 *                                     memview.dtype_is_object)
 */
    if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }

    /* "View.MemoryView":737
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 *     else:
 */
    if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }

    /* "View.MemoryView":735
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
 *                                     memviewsliceobj.to_object_func,
 *                                     memviewsliceobj.to_dtype_func,
 */
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":734
 *             new_ndim += 1
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         return memoryview_fromslice(dst, new_ndim,
 *                                     memviewsliceobj.to_object_func,
 */
  }

  /* "View.MemoryView":740
 *                                     memview.dtype_is_object)
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(((PyObject *)__pyx_r));

    /* "View.MemoryView":741
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,
 *                                     memview.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);

    /* "View.MemoryView":740
 *                                     memview.dtype_is_object)
 *     else:
 *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
 *                                     memview.dtype_is_object)
 * 
 */
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":668
 * 
 * @cname('__pyx_memview_slice')
 * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
 *     cdef int new_ndim = 0, suboffset_dim = -1, dim
 *     cdef bint negative_step
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":765
 * 
 * @cname('__pyx_memoryview_slice_memviewslice')
 * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
 *         __Pyx_memviewslice *dst,
 *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
 */

static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) {
  Py_ssize_t __pyx_v_new_shape;
  int __pyx_v_negative_step;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "View.MemoryView":785
 *     cdef bint negative_step
 * 
 *     if not is_slice:             # <<<<<<<<<<<<<<
 * 
 *         if start < 0:
 */
  __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":787
 *     if not is_slice:
 * 
 *         if start < 0:             # <<<<<<<<<<<<<<
 *             start += shape
 *         if not 0 <= start < shape:
 */
    __pyx_t_1 = ((__pyx_v_start < 0) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":788
 * 
 *         if start < 0:
 *             start += shape             # <<<<<<<<<<<<<<
 *         if not 0 <= start < shape:
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 */
      __pyx_v_start = (__pyx_v_start + __pyx_v_shape);

      /* "View.MemoryView":787
 *     if not is_slice:
 * 
 *         if start < 0:             # <<<<<<<<<<<<<<
 *             start += shape
 *         if not 0 <= start < shape:
 */
    }

    /* "View.MemoryView":789
 *         if start < 0:
 *             start += shape
 *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 *     else:
 */
    __pyx_t_1 = (0 <= __pyx_v_start);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
    }
    __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":790
 *             start += shape
 *         if not 0 <= start < shape:
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)             # <<<<<<<<<<<<<<
 *     else:
 * 
 */
      __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_Index_out_of_bounds_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":789
 *         if start < 0:
 *             start += shape
 *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
 *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
 *     else:
 */
    }

    /* "View.MemoryView":785
 *     cdef bint negative_step
 * 
 *     if not is_slice:             # <<<<<<<<<<<<<<
 * 
 *         if start < 0:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":793
 *     else:
 * 
 *         negative_step = have_step != 0 and step < 0             # <<<<<<<<<<<<<<
 * 
 *         if have_step and step == 0:
 */
  /*else*/ {
    __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_step < 0) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L6_bool_binop_done:;
    __pyx_v_negative_step = __pyx_t_2;

    /* "View.MemoryView":795
 *         negative_step = have_step != 0 and step < 0
 * 
 *         if have_step and step == 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
 * 
 */
    __pyx_t_1 = (__pyx_v_have_step != 0);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_1 = ((__pyx_v_step == 0) != 0);
    __pyx_t_2 = __pyx_t_1;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_2) {

      /* "View.MemoryView":796
 * 
 *         if have_step and step == 0:
 *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Step_may_not_be_zero_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":795
 *         negative_step = have_step != 0 and step < 0
 * 
 *         if have_step and step == 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
 * 
 */
    }

    /* "View.MemoryView":799
 * 
 * 
 *         if have_start:             # <<<<<<<<<<<<<<
 *             if start < 0:
 *                 start += shape
 */
    __pyx_t_2 = (__pyx_v_have_start != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":800
 * 
 *         if have_start:
 *             if start < 0:             # <<<<<<<<<<<<<<
 *                 start += shape
 *                 if start < 0:
 */
      __pyx_t_2 = ((__pyx_v_start < 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":801
 *         if have_start:
 *             if start < 0:
 *                 start += shape             # <<<<<<<<<<<<<<
 *                 if start < 0:
 *                     start = 0
 */
        __pyx_v_start = (__pyx_v_start + __pyx_v_shape);

        /* "View.MemoryView":802
 *             if start < 0:
 *                 start += shape
 *                 if start < 0:             # <<<<<<<<<<<<<<
 *                     start = 0
 *             elif start >= shape:
 */
        __pyx_t_2 = ((__pyx_v_start < 0) != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":803
 *                 start += shape
 *                 if start < 0:
 *                     start = 0             # <<<<<<<<<<<<<<
 *             elif start >= shape:
 *                 if negative_step:
 */
          __pyx_v_start = 0;

          /* "View.MemoryView":802
 *             if start < 0:
 *                 start += shape
 *                 if start < 0:             # <<<<<<<<<<<<<<
 *                     start = 0
 *             elif start >= shape:
 */
        }

        /* "View.MemoryView":800
 * 
 *         if have_start:
 *             if start < 0:             # <<<<<<<<<<<<<<
 *                 start += shape
 *                 if start < 0:
 */
        goto __pyx_L12;
      }

      /* "View.MemoryView":804
 *                 if start < 0:
 *                     start = 0
 *             elif start >= shape:             # <<<<<<<<<<<<<<
 *                 if negative_step:
 *                     start = shape - 1
 */
      __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":805
 *                     start = 0
 *             elif start >= shape:
 *                 if negative_step:             # <<<<<<<<<<<<<<
 *                     start = shape - 1
 *                 else:
 */
        __pyx_t_2 = (__pyx_v_negative_step != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":806
 *             elif start >= shape:
 *                 if negative_step:
 *                     start = shape - 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     start = shape
 */
          __pyx_v_start = (__pyx_v_shape - 1);

          /* "View.MemoryView":805
 *                     start = 0
 *             elif start >= shape:
 *                 if negative_step:             # <<<<<<<<<<<<<<
 *                     start = shape - 1
 *                 else:
 */
          goto __pyx_L14;
        }

        /* "View.MemoryView":808
 *                     start = shape - 1
 *                 else:
 *                     start = shape             # <<<<<<<<<<<<<<
 *         else:
 *             if negative_step:
 */
        /*else*/ {
          __pyx_v_start = __pyx_v_shape;
        }
        __pyx_L14:;

        /* "View.MemoryView":804
 *                 if start < 0:
 *                     start = 0
 *             elif start >= shape:             # <<<<<<<<<<<<<<
 *                 if negative_step:
 *                     start = shape - 1
 */
      }
      __pyx_L12:;

      /* "View.MemoryView":799
 * 
 * 
 *         if have_start:             # <<<<<<<<<<<<<<
 *             if start < 0:
 *                 start += shape
 */
      goto __pyx_L11;
    }

    /* "View.MemoryView":810
 *                     start = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 start = shape - 1
 *             else:
 */
    /*else*/ {
      __pyx_t_2 = (__pyx_v_negative_step != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":811
 *         else:
 *             if negative_step:
 *                 start = shape - 1             # <<<<<<<<<<<<<<
 *             else:
 *                 start = 0
 */
        __pyx_v_start = (__pyx_v_shape - 1);

        /* "View.MemoryView":810
 *                     start = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 start = shape - 1
 *             else:
 */
        goto __pyx_L15;
      }

      /* "View.MemoryView":813
 *                 start = shape - 1
 *             else:
 *                 start = 0             # <<<<<<<<<<<<<<
 * 
 *         if have_stop:
 */
      /*else*/ {
        __pyx_v_start = 0;
      }
      __pyx_L15:;
    }
    __pyx_L11:;

    /* "View.MemoryView":815
 *                 start = 0
 * 
 *         if have_stop:             # <<<<<<<<<<<<<<
 *             if stop < 0:
 *                 stop += shape
 */
    __pyx_t_2 = (__pyx_v_have_stop != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":816
 * 
 *         if have_stop:
 *             if stop < 0:             # <<<<<<<<<<<<<<
 *                 stop += shape
 *                 if stop < 0:
 */
      __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":817
 *         if have_stop:
 *             if stop < 0:
 *                 stop += shape             # <<<<<<<<<<<<<<
 *                 if stop < 0:
 *                     stop = 0
 */
        __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);

        /* "View.MemoryView":818
 *             if stop < 0:
 *                 stop += shape
 *                 if stop < 0:             # <<<<<<<<<<<<<<
 *                     stop = 0
 *             elif stop > shape:
 */
        __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
        if (__pyx_t_2) {

          /* "View.MemoryView":819
 *                 stop += shape
 *                 if stop < 0:
 *                     stop = 0             # <<<<<<<<<<<<<<
 *             elif stop > shape:
 *                 stop = shape
 */
          __pyx_v_stop = 0;

          /* "View.MemoryView":818
 *             if stop < 0:
 *                 stop += shape
 *                 if stop < 0:             # <<<<<<<<<<<<<<
 *                     stop = 0
 *             elif stop > shape:
 */
        }

        /* "View.MemoryView":816
 * 
 *         if have_stop:
 *             if stop < 0:             # <<<<<<<<<<<<<<
 *                 stop += shape
 *                 if stop < 0:
 */
        goto __pyx_L17;
      }

      /* "View.MemoryView":820
 *                 if stop < 0:
 *                     stop = 0
 *             elif stop > shape:             # <<<<<<<<<<<<<<
 *                 stop = shape
 *         else:
 */
      __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":821
 *                     stop = 0
 *             elif stop > shape:
 *                 stop = shape             # <<<<<<<<<<<<<<
 *         else:
 *             if negative_step:
 */
        __pyx_v_stop = __pyx_v_shape;

        /* "View.MemoryView":820
 *                 if stop < 0:
 *                     stop = 0
 *             elif stop > shape:             # <<<<<<<<<<<<<<
 *                 stop = shape
 *         else:
 */
      }
      __pyx_L17:;

      /* "View.MemoryView":815
 *                 start = 0
 * 
 *         if have_stop:             # <<<<<<<<<<<<<<
 *             if stop < 0:
 *                 stop += shape
 */
      goto __pyx_L16;
    }

    /* "View.MemoryView":823
 *                 stop = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 stop = -1
 *             else:
 */
    /*else*/ {
      __pyx_t_2 = (__pyx_v_negative_step != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":824
 *         else:
 *             if negative_step:
 *                 stop = -1             # <<<<<<<<<<<<<<
 *             else:
 *                 stop = shape
 */
        __pyx_v_stop = -1L;

        /* "View.MemoryView":823
 *                 stop = shape
 *         else:
 *             if negative_step:             # <<<<<<<<<<<<<<
 *                 stop = -1
 *             else:
 */
        goto __pyx_L19;
      }

      /* "View.MemoryView":826
 *                 stop = -1
 *             else:
 *                 stop = shape             # <<<<<<<<<<<<<<
 * 
 *         if not have_step:
 */
      /*else*/ {
        __pyx_v_stop = __pyx_v_shape;
      }
      __pyx_L19:;
    }
    __pyx_L16:;

    /* "View.MemoryView":828
 *                 stop = shape
 * 
 *         if not have_step:             # <<<<<<<<<<<<<<
 *             step = 1
 * 
 */
    __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":829
 * 
 *         if not have_step:
 *             step = 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_step = 1;

      /* "View.MemoryView":828
 *                 stop = shape
 * 
 *         if not have_step:             # <<<<<<<<<<<<<<
 *             step = 1
 * 
 */
    }

    /* "View.MemoryView":833
 * 
 *         with cython.cdivision(True):
 *             new_shape = (stop - start) // step             # <<<<<<<<<<<<<<
 * 
 *             if (stop - start) - step * new_shape:
 */
    __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);

    /* "View.MemoryView":835
 *             new_shape = (stop - start) // step
 * 
 *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
 *                 new_shape += 1
 * 
 */
    __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":836
 * 
 *             if (stop - start) - step * new_shape:
 *                 new_shape += 1             # <<<<<<<<<<<<<<
 * 
 *         if new_shape < 0:
 */
      __pyx_v_new_shape = (__pyx_v_new_shape + 1);

      /* "View.MemoryView":835
 *             new_shape = (stop - start) // step
 * 
 *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
 *                 new_shape += 1
 * 
 */
    }

    /* "View.MemoryView":838
 *                 new_shape += 1
 * 
 *         if new_shape < 0:             # <<<<<<<<<<<<<<
 *             new_shape = 0
 * 
 */
    __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":839
 * 
 *         if new_shape < 0:
 *             new_shape = 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_new_shape = 0;

      /* "View.MemoryView":838
 *                 new_shape += 1
 * 
 *         if new_shape < 0:             # <<<<<<<<<<<<<<
 *             new_shape = 0
 * 
 */
    }

    /* "View.MemoryView":842
 * 
 * 
 *         dst.strides[new_ndim] = stride * step             # <<<<<<<<<<<<<<
 *         dst.shape[new_ndim] = new_shape
 *         dst.suboffsets[new_ndim] = suboffset
 */
    (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);

    /* "View.MemoryView":843
 * 
 *         dst.strides[new_ndim] = stride * step
 *         dst.shape[new_ndim] = new_shape             # <<<<<<<<<<<<<<
 *         dst.suboffsets[new_ndim] = suboffset
 * 
 */
    (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;

    /* "View.MemoryView":844
 *         dst.strides[new_ndim] = stride * step
 *         dst.shape[new_ndim] = new_shape
 *         dst.suboffsets[new_ndim] = suboffset             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
  }
  __pyx_L3:;

  /* "View.MemoryView":847
 * 
 * 
 *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
 *         dst.data += start * stride
 *     else:
 */
  __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":848
 * 
 *     if suboffset_dim[0] < 0:
 *         dst.data += start * stride             # <<<<<<<<<<<<<<
 *     else:
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 */
    __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));

    /* "View.MemoryView":847
 * 
 * 
 *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
 *         dst.data += start * stride
 *     else:
 */
    goto __pyx_L23;
  }

  /* "View.MemoryView":850
 *         dst.data += start * stride
 *     else:
 *         dst.suboffsets[suboffset_dim[0]] += start * stride             # <<<<<<<<<<<<<<
 * 
 *     if suboffset >= 0:
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
    (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
  }
  __pyx_L23:;

  /* "View.MemoryView":852
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 * 
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         if not is_slice:
 *             if new_ndim == 0:
 */
  __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":853
 * 
 *     if suboffset >= 0:
 *         if not is_slice:             # <<<<<<<<<<<<<<
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 */
    __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":854
 *     if suboffset >= 0:
 *         if not is_slice:
 *             if new_ndim == 0:             # <<<<<<<<<<<<<<
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 */
      __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":855
 *         if not is_slice:
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset             # <<<<<<<<<<<<<<
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
 */
        __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);

        /* "View.MemoryView":854
 *     if suboffset >= 0:
 *         if not is_slice:
 *             if new_ndim == 0:             # <<<<<<<<<<<<<<
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 */
        goto __pyx_L26;
      }

      /* "View.MemoryView":857
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
 *                                      "must be indexed and not sliced", dim)
 *         else:
 */
      /*else*/ {

        /* "View.MemoryView":858
 *             else:
 *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
 *                                      "must be indexed and not sliced", dim)             # <<<<<<<<<<<<<<
 *         else:
 *             suboffset_dim[0] = new_ndim
 */
        __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_All_dimensions_preceding_dimensi, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L26:;

      /* "View.MemoryView":853
 * 
 *     if suboffset >= 0:
 *         if not is_slice:             # <<<<<<<<<<<<<<
 *             if new_ndim == 0:
 *                 dst.data = (<char **> dst.data)[0] + suboffset
 */
      goto __pyx_L25;
    }

    /* "View.MemoryView":860
 *                                      "must be indexed and not sliced", dim)
 *         else:
 *             suboffset_dim[0] = new_ndim             # <<<<<<<<<<<<<<
 * 
 *     return 0
 */
    /*else*/ {
      (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
    }
    __pyx_L25:;

    /* "View.MemoryView":852
 *         dst.suboffsets[suboffset_dim[0]] += start * stride
 * 
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         if not is_slice:
 *             if new_ndim == 0:
 */
  }

  /* "View.MemoryView":862
 *             suboffset_dim[0] = new_ndim
 * 
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":765
 * 
 * @cname('__pyx_memoryview_slice_memviewslice')
 * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
 *         __Pyx_memviewslice *dst,
 *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":868
 * 
 * @cname('__pyx_pybuffer_index')
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 */

static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) {
  Py_ssize_t __pyx_v_shape;
  Py_ssize_t __pyx_v_stride;
  Py_ssize_t __pyx_v_suboffset;
  Py_ssize_t __pyx_v_itemsize;
  char *__pyx_v_resultp;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  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("pybuffer_index", 0);

  /* "View.MemoryView":870
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t itemsize = view.itemsize
 *     cdef char *resultp
 */
  __pyx_v_suboffset = -1L;

  /* "View.MemoryView":871
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 *     cdef Py_ssize_t itemsize = view.itemsize             # <<<<<<<<<<<<<<
 *     cdef char *resultp
 * 
 */
  __pyx_t_1 = __pyx_v_view->itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":874
 *     cdef char *resultp
 * 
 *     if view.ndim == 0:             # <<<<<<<<<<<<<<
 *         shape = view.len / itemsize
 *         stride = itemsize
 */
  __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":875
 * 
 *     if view.ndim == 0:
 *         shape = view.len / itemsize             # <<<<<<<<<<<<<<
 *         stride = itemsize
 *     else:
 */
    if (unlikely(__pyx_v_itemsize == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1)  && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) {
      PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);

    /* "View.MemoryView":876
 *     if view.ndim == 0:
 *         shape = view.len / itemsize
 *         stride = itemsize             # <<<<<<<<<<<<<<
 *     else:
 *         shape = view.shape[dim]
 */
    __pyx_v_stride = __pyx_v_itemsize;

    /* "View.MemoryView":874
 *     cdef char *resultp
 * 
 *     if view.ndim == 0:             # <<<<<<<<<<<<<<
 *         shape = view.len / itemsize
 *         stride = itemsize
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":878
 *         stride = itemsize
 *     else:
 *         shape = view.shape[dim]             # <<<<<<<<<<<<<<
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:
 */
  /*else*/ {
    __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);

    /* "View.MemoryView":879
 *     else:
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]             # <<<<<<<<<<<<<<
 *         if view.suboffsets != NULL:
 *             suboffset = view.suboffsets[dim]
 */
    __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);

    /* "View.MemoryView":880
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *             suboffset = view.suboffsets[dim]
 * 
 */
    __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":881
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:
 *             suboffset = view.suboffsets[dim]             # <<<<<<<<<<<<<<
 * 
 *     if index < 0:
 */
      __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);

      /* "View.MemoryView":880
 *         shape = view.shape[dim]
 *         stride = view.strides[dim]
 *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
 *             suboffset = view.suboffsets[dim]
 * 
 */
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":883
 *             suboffset = view.suboffsets[dim]
 * 
 *     if index < 0:             # <<<<<<<<<<<<<<
 *         index += view.shape[dim]
 *         if index < 0:
 */
  __pyx_t_2 = ((__pyx_v_index < 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":884
 * 
 *     if index < 0:
 *         index += view.shape[dim]             # <<<<<<<<<<<<<<
 *         if index < 0:
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 */
    __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));

    /* "View.MemoryView":885
 *     if index < 0:
 *         index += view.shape[dim]
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
    __pyx_t_2 = ((__pyx_v_index < 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":886
 *         index += view.shape[dim]
 *         if index < 0:
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
 * 
 *     if index >= shape:
 */
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__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[4]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__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[4]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":885
 *     if index < 0:
 *         index += view.shape[dim]
 *         if index < 0:             # <<<<<<<<<<<<<<
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
    }

    /* "View.MemoryView":883
 *             suboffset = view.suboffsets[dim]
 * 
 *     if index < 0:             # <<<<<<<<<<<<<<
 *         index += view.shape[dim]
 *         if index < 0:
 */
  }

  /* "View.MemoryView":888
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     if index >= shape:             # <<<<<<<<<<<<<<
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
  __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":889
 * 
 *     if index >= shape:
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
 * 
 *     resultp = bufp + index * stride
 */
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 889; __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[4]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__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[4]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":888
 *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     if index >= shape:             # <<<<<<<<<<<<<<
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 */
  }

  /* "View.MemoryView":891
 *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
 * 
 *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
 *     if suboffset >= 0:
 *         resultp = (<char **> resultp)[0] + suboffset
 */
  __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));

  /* "View.MemoryView":892
 * 
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 */
  __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":893
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:
 *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
 * 
 *     return resultp
 */
    __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);

    /* "View.MemoryView":892
 * 
 *     resultp = bufp + index * stride
 *     if suboffset >= 0:             # <<<<<<<<<<<<<<
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 */
  }

  /* "View.MemoryView":895
 *         resultp = (<char **> resultp)[0] + suboffset
 * 
 *     return resultp             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_resultp;
  goto __pyx_L0;

  /* "View.MemoryView":868
 * 
 * @cname('__pyx_pybuffer_index')
 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
 *                           Py_ssize_t dim) except NULL:
 *     cdef Py_ssize_t shape, stride, suboffset = -1
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":901
 * 
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 */

static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
  int __pyx_v_ndim;
  Py_ssize_t *__pyx_v_shape;
  Py_ssize_t *__pyx_v_strides;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_r;
  int __pyx_t_1;
  Py_ssize_t *__pyx_t_2;
  long __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "View.MemoryView":902
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
 *     cdef int ndim = memslice.memview.view.ndim             # <<<<<<<<<<<<<<
 * 
 *     cdef Py_ssize_t *shape = memslice.shape
 */
  __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
  __pyx_v_ndim = __pyx_t_1;

  /* "View.MemoryView":904
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 *     cdef Py_ssize_t *shape = memslice.shape             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t *strides = memslice.strides
 * 
 */
  __pyx_t_2 = __pyx_v_memslice->shape;
  __pyx_v_shape = __pyx_t_2;

  /* "View.MemoryView":905
 * 
 *     cdef Py_ssize_t *shape = memslice.shape
 *     cdef Py_ssize_t *strides = memslice.strides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __pyx_v_memslice->strides;
  __pyx_v_strides = __pyx_t_2;

  /* "View.MemoryView":909
 * 
 *     cdef int i, j
 *     for i in range(ndim / 2):             # <<<<<<<<<<<<<<
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]
 */
  __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
  for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":910
 *     cdef int i, j
 *     for i in range(ndim / 2):
 *         j = ndim - 1 - i             # <<<<<<<<<<<<<<
 *         strides[i], strides[j] = strides[j], strides[i]
 *         shape[i], shape[j] = shape[j], shape[i]
 */
    __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);

    /* "View.MemoryView":911
 *     for i in range(ndim / 2):
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]             # <<<<<<<<<<<<<<
 *         shape[i], shape[j] = shape[j], shape[i]
 * 
 */
    __pyx_t_4 = (__pyx_v_strides[__pyx_v_j]);
    __pyx_t_5 = (__pyx_v_strides[__pyx_v_i]);
    (__pyx_v_strides[__pyx_v_i]) = __pyx_t_4;
    (__pyx_v_strides[__pyx_v_j]) = __pyx_t_5;

    /* "View.MemoryView":912
 *         j = ndim - 1 - i
 *         strides[i], strides[j] = strides[j], strides[i]
 *         shape[i], shape[j] = shape[j], shape[i]             # <<<<<<<<<<<<<<
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
 */
    __pyx_t_5 = (__pyx_v_shape[__pyx_v_j]);
    __pyx_t_4 = (__pyx_v_shape[__pyx_v_i]);
    (__pyx_v_shape[__pyx_v_i]) = __pyx_t_5;
    (__pyx_v_shape[__pyx_v_j]) = __pyx_t_4;

    /* "View.MemoryView":914
 *         shape[i], shape[j] = shape[j], shape[i]
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 */
    __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_6) {

      /* "View.MemoryView":915
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")             # <<<<<<<<<<<<<<
 * 
 *     return 1
 */
      __pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, __pyx_k_Cannot_transpose_memoryview_with); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":914
 *         shape[i], shape[j] = shape[j], shape[i]
 * 
 *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 */
    }
  }

  /* "View.MemoryView":917
 *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
 * 
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "View.MemoryView":901
 * 
 * @cname('__pyx_memslice_transpose')
 * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
 *     cdef int ndim = memslice.memview.view.ndim
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":934
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 */

/* Python wrapper */
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "View.MemoryView":935
 * 
 *     def __dealloc__(self):
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)             # <<<<<<<<<<<<<<
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 */
  __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);

  /* "View.MemoryView":934
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":937
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)
 */

static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
  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("convert_item_to_object", 0);

  /* "View.MemoryView":938
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
 *             return self.to_object_func(itemp)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":939
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)             # <<<<<<<<<<<<<<
 *         else:
 *             return memoryview.convert_item_to_object(self, itemp)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "View.MemoryView":938
 * 
 *     cdef convert_item_to_object(self, char *itemp):
 *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
 *             return self.to_object_func(itemp)
 *         else:
 */
  }

  /* "View.MemoryView":941
 *             return self.to_object_func(itemp)
 *         else:
 *             return memoryview.convert_item_to_object(self, itemp)             # <<<<<<<<<<<<<<
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "View.MemoryView":937
 *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
 * 
 *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
 *         if self.to_object_func != NULL:
 *             return self.to_object_func(itemp)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":943
 *             return memoryview.convert_item_to_object(self, itemp)
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)
 */

static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __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("assign_item_from_object", 0);

  /* "View.MemoryView":944
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
 *             self.to_dtype_func(itemp, value)
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":945
 *     cdef assign_item_from_object(self, char *itemp, object value):
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)             # <<<<<<<<<<<<<<
 *         else:
 *             memoryview.assign_item_from_object(self, itemp, value)
 */
    __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":944
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):
 *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
 *             self.to_dtype_func(itemp, value)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":947
 *             self.to_dtype_func(itemp, value)
 *         else:
 *             memoryview.assign_item_from_object(self, itemp, value)             # <<<<<<<<<<<<<<
 * 
 *     property base:
 */
  /*else*/ {
    __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "View.MemoryView":943
 *             return memoryview.convert_item_to_object(self, itemp)
 * 
 *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
 *         if self.to_dtype_func != NULL:
 *             self.to_dtype_func(itemp, value)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":951
 *     property base:
 *         @cname('__pyx_memoryviewslice__get__base')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.from_object
 * 
 */

/* Python wrapper */
static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "View.MemoryView":952
 *         @cname('__pyx_memoryviewslice__get__base')
 *         def __get__(self):
 *             return self.from_object             # <<<<<<<<<<<<<<
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->from_object);
  __pyx_r = __pyx_v_self->from_object;
  goto __pyx_L0;

  /* "View.MemoryView":951
 *     property base:
 *         @cname('__pyx_memoryviewslice__get__base')
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.from_object
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":958
 * 
 * @cname('__pyx_memoryview_fromslice')
 * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
 *                           int ndim,
 *                           object (*to_object_func)(char *),
 */

static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) {
  struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
  Py_ssize_t __pyx_v_suboffset;
  PyObject *__pyx_v_length = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_TypeInfo *__pyx_t_4;
  Py_buffer __pyx_t_5;
  Py_ssize_t *__pyx_t_6;
  Py_ssize_t *__pyx_t_7;
  Py_ssize_t *__pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("memoryview_fromslice", 0);

  /* "View.MemoryView":966
 *     cdef _memoryviewslice result
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":967
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:
 *         return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;

    /* "View.MemoryView":966
 *     cdef _memoryviewslice result
 * 
 *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "View.MemoryView":972
 * 
 * 
 *     result = _memoryviewslice(None, 0, dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 *     result.from_slice = memviewslice
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 972; __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[4]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "View.MemoryView":974
 *     result = _memoryviewslice(None, 0, dtype_is_object)
 * 
 *     result.from_slice = memviewslice             # <<<<<<<<<<<<<<
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)
 * 
 */
  __pyx_v_result->from_slice = __pyx_v_memviewslice;

  /* "View.MemoryView":975
 * 
 *     result.from_slice = memviewslice
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base
 */
  __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);

  /* "View.MemoryView":977
 *     __PYX_INC_MEMVIEW(&memviewslice, 1)
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base             # <<<<<<<<<<<<<<
 *     result.typeinfo = memviewslice.memview.typeinfo
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_result->from_object);
  __Pyx_DECREF(__pyx_v_result->from_object);
  __pyx_v_result->from_object = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "View.MemoryView":978
 * 
 *     result.from_object = (<memoryview> memviewslice.memview).base
 *     result.typeinfo = memviewslice.memview.typeinfo             # <<<<<<<<<<<<<<
 * 
 *     result.view = memviewslice.memview.view
 */
  __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
  __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;

  /* "View.MemoryView":980
 *     result.typeinfo = memviewslice.memview.typeinfo
 * 
 *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim
 */
  __pyx_t_5 = __pyx_v_memviewslice.memview->view;
  __pyx_v_result->__pyx_base.view = __pyx_t_5;

  /* "View.MemoryView":981
 * 
 *     result.view = memviewslice.memview.view
 *     result.view.buf = <void *> memviewslice.data             # <<<<<<<<<<<<<<
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 */
  __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);

  /* "View.MemoryView":982
 *     result.view = memviewslice.memview.view
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim             # <<<<<<<<<<<<<<
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 *     Py_INCREF(Py_None)
 */
  __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;

  /* "View.MemoryView":983
 *     result.view.buf = <void *> memviewslice.data
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None             # <<<<<<<<<<<<<<
 *     Py_INCREF(Py_None)
 * 
 */
  ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;

  /* "View.MemoryView":984
 *     result.view.ndim = ndim
 *     (<__pyx_buffer *> &result.view).obj = Py_None
 *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
 * 
 *     result.flags = PyBUF_RECORDS
 */
  Py_INCREF(Py_None);

  /* "View.MemoryView":986
 *     Py_INCREF(Py_None)
 * 
 *     result.flags = PyBUF_RECORDS             # <<<<<<<<<<<<<<
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 */
  __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;

  /* "View.MemoryView":988
 *     result.flags = PyBUF_RECORDS
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
 * 
 */
  __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);

  /* "View.MemoryView":989
 * 
 *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
 *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);

  /* "View.MemoryView":992
 * 
 * 
 *     result.view.suboffsets = NULL             # <<<<<<<<<<<<<<
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:
 */
  __pyx_v_result->__pyx_base.view.suboffsets = NULL;

  /* "View.MemoryView":993
 * 
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:             # <<<<<<<<<<<<<<
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 */
  __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
  for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
    __pyx_t_6 = __pyx_t_8;
    __pyx_v_suboffset = (__pyx_t_6[0]);

    /* "View.MemoryView":994
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break
 */
    __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
    if (__pyx_t_1) {

      /* "View.MemoryView":995
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);

      /* "View.MemoryView":996
 *         if suboffset >= 0:
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break             # <<<<<<<<<<<<<<
 * 
 *     result.view.len = result.view.itemsize
 */
      goto __pyx_L5_break;

      /* "View.MemoryView":994
 *     result.view.suboffsets = NULL
 *     for suboffset in result.from_slice.suboffsets[:ndim]:
 *         if suboffset >= 0:             # <<<<<<<<<<<<<<
 *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
 *             break
 */
    }
  }
  __pyx_L5_break:;

  /* "View.MemoryView":998
 *             break
 * 
 *     result.view.len = result.view.itemsize             # <<<<<<<<<<<<<<
 *     for length in result.view.shape[:ndim]:
 *         result.view.len *= length
 */
  __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
  __pyx_v_result->__pyx_base.view.len = __pyx_t_9;

  /* "View.MemoryView":999
 * 
 *     result.view.len = result.view.itemsize
 *     for length in result.view.shape[:ndim]:             # <<<<<<<<<<<<<<
 *         result.view.len *= length
 * 
 */
  __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
  for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
    __pyx_t_6 = __pyx_t_8;
    __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "View.MemoryView":1000
 *     result.view.len = result.view.itemsize
 *     for length in result.view.shape[:ndim]:
 *         result.view.len *= length             # <<<<<<<<<<<<<<
 * 
 *     result.to_object_func = to_object_func
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
  }

  /* "View.MemoryView":1002
 *         result.view.len *= length
 * 
 *     result.to_object_func = to_object_func             # <<<<<<<<<<<<<<
 *     result.to_dtype_func = to_dtype_func
 * 
 */
  __pyx_v_result->to_object_func = __pyx_v_to_object_func;

  /* "View.MemoryView":1003
 * 
 *     result.to_object_func = to_object_func
 *     result.to_dtype_func = to_dtype_func             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
  __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;

  /* "View.MemoryView":1005
 *     result.to_dtype_func = to_dtype_func
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  /* "View.MemoryView":958
 * 
 * @cname('__pyx_memoryview_fromslice')
 * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
 *                           int ndim,
 *                           object (*to_object_func)(char *),
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_length);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1008
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 */

static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
  struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
  __Pyx_memviewslice *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __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("get_slice_from_memview", 0);

  /* "View.MemoryView":1011
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         obj = memview
 *         return &obj.from_slice
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1012
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):
 *         obj = memview             # <<<<<<<<<<<<<<
 *         return &obj.from_slice
 *     else:
 */
    if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((PyObject *)__pyx_v_memview);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "View.MemoryView":1013
 *     if isinstance(memview, _memoryviewslice):
 *         obj = memview
 *         return &obj.from_slice             # <<<<<<<<<<<<<<
 *     else:
 *         slice_copy(memview, mslice)
 */
    __pyx_r = (&__pyx_v_obj->from_slice);
    goto __pyx_L0;

    /* "View.MemoryView":1011
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         obj = memview
 *         return &obj.from_slice
 */
  }

  /* "View.MemoryView":1015
 *         return &obj.from_slice
 *     else:
 *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
 *         return mslice
 * 
 */
  /*else*/ {
    __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);

    /* "View.MemoryView":1016
 *     else:
 *         slice_copy(memview, mslice)
 *         return mslice             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_slice_copy')
 */
    __pyx_r = __pyx_v_mslice;
    goto __pyx_L0;
  }

  /* "View.MemoryView":1008
 * 
 * @cname('__pyx_memoryview_get_slice_from_memoryview')
 * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
 *                                                    __Pyx_memviewslice *mslice):
 *     cdef _memoryviewslice obj
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_obj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1019
 * 
 * @cname('__pyx_memoryview_slice_copy')
 * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
 *     cdef int dim
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 */

static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
  int __pyx_v_dim;
  Py_ssize_t *__pyx_v_shape;
  Py_ssize_t *__pyx_v_strides;
  Py_ssize_t *__pyx_v_suboffsets;
  __Pyx_RefNannyDeclarations
  Py_ssize_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  __Pyx_RefNannySetupContext("slice_copy", 0);

  /* "View.MemoryView":1023
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 * 
 *     shape = memview.view.shape             # <<<<<<<<<<<<<<
 *     strides = memview.view.strides
 *     suboffsets = memview.view.suboffsets
 */
  __pyx_t_1 = __pyx_v_memview->view.shape;
  __pyx_v_shape = __pyx_t_1;

  /* "View.MemoryView":1024
 * 
 *     shape = memview.view.shape
 *     strides = memview.view.strides             # <<<<<<<<<<<<<<
 *     suboffsets = memview.view.suboffsets
 * 
 */
  __pyx_t_1 = __pyx_v_memview->view.strides;
  __pyx_v_strides = __pyx_t_1;

  /* "View.MemoryView":1025
 *     shape = memview.view.shape
 *     strides = memview.view.strides
 *     suboffsets = memview.view.suboffsets             # <<<<<<<<<<<<<<
 * 
 *     dst.memview = <__pyx_memoryview *> memview
 */
  __pyx_t_1 = __pyx_v_memview->view.suboffsets;
  __pyx_v_suboffsets = __pyx_t_1;

  /* "View.MemoryView":1027
 *     suboffsets = memview.view.suboffsets
 * 
 *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
 *     dst.data = <char *> memview.view.buf
 * 
 */
  __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);

  /* "View.MemoryView":1028
 * 
 *     dst.memview = <__pyx_memoryview *> memview
 *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
 * 
 *     for dim in range(memview.view.ndim):
 */
  __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);

  /* "View.MemoryView":1030
 *     dst.data = <char *> memview.view.buf
 * 
 *     for dim in range(memview.view.ndim):             # <<<<<<<<<<<<<<
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]
 */
  __pyx_t_2 = __pyx_v_memview->view.ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_dim = __pyx_t_3;

    /* "View.MemoryView":1031
 * 
 *     for dim in range(memview.view.ndim):
 *         dst.shape[dim] = shape[dim]             # <<<<<<<<<<<<<<
 *         dst.strides[dim] = strides[dim]
 *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
 */
    (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);

    /* "View.MemoryView":1032
 *     for dim in range(memview.view.ndim):
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]             # <<<<<<<<<<<<<<
 *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
 * 
 */
    (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);

    /* "View.MemoryView":1033
 *         dst.shape[dim] = shape[dim]
 *         dst.strides[dim] = strides[dim]
 *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_object')
 */
    if ((__pyx_v_suboffsets != 0)) {
      __pyx_t_4 = (__pyx_v_suboffsets[__pyx_v_dim]);
    } else {
      __pyx_t_4 = -1L;
    }
    (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_4;
  }

  /* "View.MemoryView":1019
 * 
 * @cname('__pyx_memoryview_slice_copy')
 * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
 *     cdef int dim
 *     cdef (Py_ssize_t*) shape, strides, suboffsets
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":1036
 * 
 * @cname('__pyx_memoryview_copy_object')
 * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 */

static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
  __Pyx_memviewslice __pyx_v_memviewslice;
  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("memoryview_copy", 0);

  /* "View.MemoryView":1039
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 *     slice_copy(memview, &memviewslice)             # <<<<<<<<<<<<<<
 *     return memoryview_copy_from_slice(memview, &memviewslice)
 * 
 */
  __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));

  /* "View.MemoryView":1040
 *     cdef __Pyx_memviewslice memviewslice
 *     slice_copy(memview, &memviewslice)
 *     return memoryview_copy_from_slice(memview, &memviewslice)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1036
 * 
 * @cname('__pyx_memoryview_copy_object')
 * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
 *     "Create a new memoryview object"
 *     cdef __Pyx_memviewslice memviewslice
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1043
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
 *     """
 *     Create a new memoryview object from a given memoryview object and slice.
 */

static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
  PyObject *(*__pyx_v_to_object_func)(char *);
  int (*__pyx_v_to_dtype_func)(char *, PyObject *);
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *(*__pyx_t_3)(char *);
  int (*__pyx_t_4)(char *, PyObject *);
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);

  /* "View.MemoryView":1050
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         to_object_func = (<_memoryviewslice> memview).to_object_func
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); 
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1051
 * 
 *     if isinstance(memview, _memoryviewslice):
 *         to_object_func = (<_memoryviewslice> memview).to_object_func             # <<<<<<<<<<<<<<
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 *     else:
 */
    __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
    __pyx_v_to_object_func = __pyx_t_3;

    /* "View.MemoryView":1052
 *     if isinstance(memview, _memoryviewslice):
 *         to_object_func = (<_memoryviewslice> memview).to_object_func
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func             # <<<<<<<<<<<<<<
 *     else:
 *         to_object_func = NULL
 */
    __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
    __pyx_v_to_dtype_func = __pyx_t_4;

    /* "View.MemoryView":1050
 *     cdef int (*to_dtype_func)(char *, object) except 0
 * 
 *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
 *         to_object_func = (<_memoryviewslice> memview).to_object_func
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1054
 *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
 *     else:
 *         to_object_func = NULL             # <<<<<<<<<<<<<<
 *         to_dtype_func = NULL
 * 
 */
  /*else*/ {
    __pyx_v_to_object_func = NULL;

    /* "View.MemoryView":1055
 *     else:
 *         to_object_func = NULL
 *         to_dtype_func = NULL             # <<<<<<<<<<<<<<
 * 
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
 */
    __pyx_v_to_dtype_func = NULL;
  }
  __pyx_L3:;

  /* "View.MemoryView":1057
 *         to_dtype_func = NULL
 * 
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,             # <<<<<<<<<<<<<<
 *                                 to_object_func, to_dtype_func,
 *                                 memview.dtype_is_object)
 */
  __Pyx_XDECREF(__pyx_r);

  /* "View.MemoryView":1059
 *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
 *                                 to_object_func, to_dtype_func,
 *                                 memview.dtype_is_object)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1043
 * 
 * @cname('__pyx_memoryview_copy_object_from_slice')
 * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
 *     """
 *     Create a new memoryview object from a given memoryview object and slice.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "View.MemoryView":1065
 * 
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
 *     if arg < 0:
 *         return -arg
 */

static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
  Py_ssize_t __pyx_r;
  int __pyx_t_1;

  /* "View.MemoryView":1066
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:             # <<<<<<<<<<<<<<
 *         return -arg
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1067
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:
 *         return -arg             # <<<<<<<<<<<<<<
 *     else:
 *         return arg
 */
    __pyx_r = (-__pyx_v_arg);
    goto __pyx_L0;

    /* "View.MemoryView":1066
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
 *     if arg < 0:             # <<<<<<<<<<<<<<
 *         return -arg
 *     else:
 */
  }

  /* "View.MemoryView":1069
 *         return -arg
 *     else:
 *         return arg             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_get_best_slice_order')
 */
  /*else*/ {
    __pyx_r = __pyx_v_arg;
    goto __pyx_L0;
  }

  /* "View.MemoryView":1065
 * 
 * 
 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
 *     if arg < 0:
 *         return -arg
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1072
 * 
 * @cname('__pyx_get_best_slice_order')
 * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Figure out the best memory access order for a given slice.
 */

static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
  int __pyx_v_i;
  Py_ssize_t __pyx_v_c_stride;
  Py_ssize_t __pyx_v_f_stride;
  char __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1077
 *     """
 *     cdef int i
 *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t f_stride = 0
 * 
 */
  __pyx_v_c_stride = 0;

  /* "View.MemoryView":1078
 *     cdef int i
 *     cdef Py_ssize_t c_stride = 0
 *     cdef Py_ssize_t f_stride = 0             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim - 1, -1, -1):
 */
  __pyx_v_f_stride = 0;

  /* "View.MemoryView":1080
 *     cdef Py_ssize_t f_stride = 0
 * 
 *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]
 */
  for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":1081
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             c_stride = mslice.strides[i]
 *             break
 */
    __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1082
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);

      /* "View.MemoryView":1083
 *         if mslice.shape[i] > 1:
 *             c_stride = mslice.strides[i]
 *             break             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
      goto __pyx_L4_break;

      /* "View.MemoryView":1081
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             c_stride = mslice.strides[i]
 *             break
 */
    }
  }
  __pyx_L4_break:;

  /* "View.MemoryView":1085
 *             break
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]
 */
  __pyx_t_1 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1086
 * 
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             f_stride = mslice.strides[i]
 *             break
 */
    __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1087
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
 *             break
 * 
 */
      __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);

      /* "View.MemoryView":1088
 *         if mslice.shape[i] > 1:
 *             f_stride = mslice.strides[i]
 *             break             # <<<<<<<<<<<<<<
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
 */
      goto __pyx_L7_break;

      /* "View.MemoryView":1086
 * 
 *     for i in range(ndim):
 *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
 *             f_stride = mslice.strides[i]
 *             break
 */
    }
  }
  __pyx_L7_break:;

  /* "View.MemoryView":1090
 *             break
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
 *         return 'C'
 *     else:
 */
  __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1091
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
 *         return 'C'             # <<<<<<<<<<<<<<
 *     else:
 *         return 'F'
 */
    __pyx_r = 'C';
    goto __pyx_L0;

    /* "View.MemoryView":1090
 *             break
 * 
 *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
 *         return 'C'
 *     else:
 */
  }

  /* "View.MemoryView":1093
 *         return 'C'
 *     else:
 *         return 'F'             # <<<<<<<<<<<<<<
 * 
 * @cython.cdivision(True)
 */
  /*else*/ {
    __pyx_r = 'F';
    goto __pyx_L0;
  }

  /* "View.MemoryView":1072
 * 
 * @cname('__pyx_get_best_slice_order')
 * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Figure out the best memory access order for a given slice.
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1096
 * 
 * @cython.cdivision(True)
 * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
 *                                    char *dst_data, Py_ssize_t *dst_strides,
 *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
 */

static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
  Py_ssize_t __pyx_v_dst_extent;
  Py_ssize_t __pyx_v_src_stride;
  Py_ssize_t __pyx_v_dst_stride;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;

  /* "View.MemoryView":1103
 * 
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t src_extent = src_shape[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]
 */
  __pyx_v_src_extent = (__pyx_v_src_shape[0]);

  /* "View.MemoryView":1104
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t src_extent = src_shape[0]
 *     cdef Py_ssize_t dst_extent = dst_shape[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t src_stride = src_strides[0]
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 */
  __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);

  /* "View.MemoryView":1105
 *     cdef Py_ssize_t src_extent = src_shape[0]
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 */
  __pyx_v_src_stride = (__pyx_v_src_strides[0]);

  /* "View.MemoryView":1106
 *     cdef Py_ssize_t dst_extent = dst_shape[0]
 *     cdef Py_ssize_t src_stride = src_strides[0]
 *     cdef Py_ssize_t dst_stride = dst_strides[0]             # <<<<<<<<<<<<<<
 * 
 *     if ndim == 1:
 */
  __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);

  /* "View.MemoryView":1108
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 */
  __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1109
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
    __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }

    /* "View.MemoryView":1110
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):             # <<<<<<<<<<<<<<
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 *        else:
 */
    __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
    if (__pyx_t_2) {
      __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
    }
    __pyx_t_3 = (__pyx_t_2 != 0);
    __pyx_t_1 = __pyx_t_3;
    __pyx_L5_bool_binop_done:;

    /* "View.MemoryView":1109
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
    if (__pyx_t_1) {

      /* "View.MemoryView":1111
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)             # <<<<<<<<<<<<<<
 *        else:
 *            for i in range(dst_extent):
 */
      memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent));

      /* "View.MemoryView":1109
 * 
 *     if ndim == 1:
 *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 */
      goto __pyx_L4;
    }

    /* "View.MemoryView":1113
 *            memcpy(dst_data, src_data, itemsize * dst_extent)
 *        else:
 *            for i in range(dst_extent):             # <<<<<<<<<<<<<<
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride
 */
    /*else*/ {
      __pyx_t_4 = __pyx_v_dst_extent;
      for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
        __pyx_v_i = __pyx_t_5;

        /* "View.MemoryView":1114
 *        else:
 *            for i in range(dst_extent):
 *                memcpy(dst_data, src_data, itemsize)             # <<<<<<<<<<<<<<
 *                src_data += src_stride
 *                dst_data += dst_stride
 */
        memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize);

        /* "View.MemoryView":1115
 *            for i in range(dst_extent):
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride             # <<<<<<<<<<<<<<
 *                dst_data += dst_stride
 *     else:
 */
        __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);

        /* "View.MemoryView":1116
 *                memcpy(dst_data, src_data, itemsize)
 *                src_data += src_stride
 *                dst_data += dst_stride             # <<<<<<<<<<<<<<
 *     else:
 *         for i in range(dst_extent):
 */
        __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
      }
    }
    __pyx_L4:;

    /* "View.MemoryView":1108
 *     cdef Py_ssize_t dst_stride = dst_strides[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *        if (src_stride > 0 and dst_stride > 0 and
 *            <size_t> src_stride == itemsize == <size_t> dst_stride):
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1118
 *                dst_data += dst_stride
 *     else:
 *         for i in range(dst_extent):             # <<<<<<<<<<<<<<
 *             _copy_strided_to_strided(src_data, src_strides + 1,
 *                                      dst_data, dst_strides + 1,
 */
  /*else*/ {
    __pyx_t_4 = __pyx_v_dst_extent;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_i = __pyx_t_5;

      /* "View.MemoryView":1119
 *     else:
 *         for i in range(dst_extent):
 *             _copy_strided_to_strided(src_data, src_strides + 1,             # <<<<<<<<<<<<<<
 *                                      dst_data, dst_strides + 1,
 *                                      src_shape + 1, dst_shape + 1,
 */
      _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize);

      /* "View.MemoryView":1123
 *                                      src_shape + 1, dst_shape + 1,
 *                                      ndim - 1, itemsize)
 *             src_data += src_stride             # <<<<<<<<<<<<<<
 *             dst_data += dst_stride
 * 
 */
      __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);

      /* "View.MemoryView":1124
 *                                      ndim - 1, itemsize)
 *             src_data += src_stride
 *             dst_data += dst_stride             # <<<<<<<<<<<<<<
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
 */
      __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1096
 * 
 * @cython.cdivision(True)
 * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
 *                                    char *dst_data, Py_ssize_t *dst_strides,
 *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
 */

  /* function exit code */
}

/* "View.MemoryView":1126
 *             dst_data += dst_stride
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 */

static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) {

  /* "View.MemoryView":1129
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 *     _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides,             # <<<<<<<<<<<<<<
 *                              src.shape, dst.shape, ndim, itemsize)
 * 
 */
  _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize);

  /* "View.MemoryView":1126
 *             dst_data += dst_stride
 * 
 * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice *dst,
 *                                   int ndim, size_t itemsize) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1133
 * 
 * @cname('__pyx_memoryview_slice_get_size')
 * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 */

static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
  int __pyx_v_i;
  Py_ssize_t __pyx_v_size;
  Py_ssize_t __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1136
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 *     cdef Py_ssize_t size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
  __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
  __pyx_v_size = __pyx_t_1;

  /* "View.MemoryView":1138
 *     cdef Py_ssize_t size = src.memview.view.itemsize
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         size *= src.shape[i]
 * 
 */
  __pyx_t_2 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1139
 * 
 *     for i in range(ndim):
 *         size *= src.shape[i]             # <<<<<<<<<<<<<<
 * 
 *     return size
 */
    __pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i]));
  }

  /* "View.MemoryView":1141
 *         size *= src.shape[i]
 * 
 *     return size             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_fill_contig_strides_array')
 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  /* "View.MemoryView":1133
 * 
 * @cname('__pyx_memoryview_slice_get_size')
 * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
 *     "Return the size of the memory occupied by the slice in number of bytes"
 *     cdef int i
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1144
 * 
 * @cname('__pyx_fill_contig_strides_array')
 * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
 *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
 *                 int ndim, char order) nogil:
 */

static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) {
  int __pyx_v_idx;
  Py_ssize_t __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;

  /* "View.MemoryView":1153
 *     cdef int idx
 * 
 *     if order == 'F':             # <<<<<<<<<<<<<<
 *         for idx in range(ndim):
 *             strides[idx] = stride
 */
  __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1154
 * 
 *     if order == 'F':
 *         for idx in range(ndim):             # <<<<<<<<<<<<<<
 *             strides[idx] = stride
 *             stride = stride * shape[idx]
 */
    __pyx_t_2 = __pyx_v_ndim;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_idx = __pyx_t_3;

      /* "View.MemoryView":1155
 *     if order == 'F':
 *         for idx in range(ndim):
 *             strides[idx] = stride             # <<<<<<<<<<<<<<
 *             stride = stride * shape[idx]
 *     else:
 */
      (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;

      /* "View.MemoryView":1156
 *         for idx in range(ndim):
 *             strides[idx] = stride
 *             stride = stride * shape[idx]             # <<<<<<<<<<<<<<
 *     else:
 *         for idx in range(ndim - 1, -1, -1):
 */
      __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
    }

    /* "View.MemoryView":1153
 *     cdef int idx
 * 
 *     if order == 'F':             # <<<<<<<<<<<<<<
 *         for idx in range(ndim):
 *             strides[idx] = stride
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1158
 *             stride = stride * shape[idx]
 *     else:
 *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *             strides[idx] = stride
 *             stride = stride * shape[idx]
 */
  /*else*/ {
    for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1L; __pyx_t_2-=1) {
      __pyx_v_idx = __pyx_t_2;

      /* "View.MemoryView":1159
 *     else:
 *         for idx in range(ndim - 1, -1, -1):
 *             strides[idx] = stride             # <<<<<<<<<<<<<<
 *             stride = stride * shape[idx]
 * 
 */
      (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;

      /* "View.MemoryView":1160
 *         for idx in range(ndim - 1, -1, -1):
 *             strides[idx] = stride
 *             stride = stride * shape[idx]             # <<<<<<<<<<<<<<
 * 
 *     return stride
 */
      __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1162
 *             stride = stride * shape[idx]
 * 
 *     return stride             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 */
  __pyx_r = __pyx_v_stride;
  goto __pyx_L0;

  /* "View.MemoryView":1144
 * 
 * @cname('__pyx_fill_contig_strides_array')
 * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
 *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
 *                 int ndim, char order) nogil:
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1165
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                              __Pyx_memviewslice *tmpslice,
 *                              char order,
 */

static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) {
  int __pyx_v_i;
  void *__pyx_v_result;
  size_t __pyx_v_itemsize;
  size_t __pyx_v_size;
  void *__pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  struct __pyx_memoryview_obj *__pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "View.MemoryView":1176
 *     cdef void *result
 * 
 *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 *     cdef size_t size = slice_get_size(src, ndim)
 * 
 */
  __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":1177
 * 
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef size_t size = slice_get_size(src, ndim)             # <<<<<<<<<<<<<<
 * 
 *     result = malloc(size)
 */
  __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);

  /* "View.MemoryView":1179
 *     cdef size_t size = slice_get_size(src, ndim)
 * 
 *     result = malloc(size)             # <<<<<<<<<<<<<<
 *     if not result:
 *         _err(MemoryError, NULL)
 */
  __pyx_v_result = malloc(__pyx_v_size);

  /* "View.MemoryView":1180
 * 
 *     result = malloc(size)
 *     if not result:             # <<<<<<<<<<<<<<
 *         _err(MemoryError, NULL)
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1181
 *     result = malloc(size)
 *     if not result:
 *         _err(MemoryError, NULL)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":1180
 * 
 *     result = malloc(size)
 *     if not result:             # <<<<<<<<<<<<<<
 *         _err(MemoryError, NULL)
 * 
 */
  }

  /* "View.MemoryView":1184
 * 
 * 
 *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):
 */
  __pyx_v_tmpslice->data = ((char *)__pyx_v_result);

  /* "View.MemoryView":1185
 * 
 *     tmpslice.data = <char *> result
 *     tmpslice.memview = src.memview             # <<<<<<<<<<<<<<
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]
 */
  __pyx_t_4 = __pyx_v_src->memview;
  __pyx_v_tmpslice->memview = __pyx_t_4;

  /* "View.MemoryView":1186
 *     tmpslice.data = <char *> result
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         tmpslice.shape[i] = src.shape[i]
 *         tmpslice.suboffsets[i] = -1
 */
  __pyx_t_3 = __pyx_v_ndim;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "View.MemoryView":1187
 *     tmpslice.memview = src.memview
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]             # <<<<<<<<<<<<<<
 *         tmpslice.suboffsets[i] = -1
 * 
 */
    (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);

    /* "View.MemoryView":1188
 *     for i in range(ndim):
 *         tmpslice.shape[i] = src.shape[i]
 *         tmpslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
 * 
 *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
 */
    (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
  }

  /* "View.MemoryView":1190
 *         tmpslice.suboffsets[i] = -1
 * 
 *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,             # <<<<<<<<<<<<<<
 *                               ndim, order)
 * 
 */
  __pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order);

  /* "View.MemoryView":1194
 * 
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if tmpslice.shape[i] == 1:
 *             tmpslice.strides[i] = 0
 */
  __pyx_t_3 = __pyx_v_ndim;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "View.MemoryView":1195
 * 
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
 *             tmpslice.strides[i] = 0
 * 
 */
    __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1196
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:
 *             tmpslice.strides[i] = 0             # <<<<<<<<<<<<<<
 * 
 *     if slice_is_contig(src, order, ndim):
 */
      (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;

      /* "View.MemoryView":1195
 * 
 *     for i in range(ndim):
 *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
 *             tmpslice.strides[i] = 0
 * 
 */
    }
  }

  /* "View.MemoryView":1198
 *             tmpslice.strides[i] = 0
 * 
 *     if slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
 *         memcpy(result, src.data, size)
 *     else:
 */
  __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1199
 * 
 *     if slice_is_contig(src, order, ndim):
 *         memcpy(result, src.data, size)             # <<<<<<<<<<<<<<
 *     else:
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
 */
    memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size);

    /* "View.MemoryView":1198
 *             tmpslice.strides[i] = 0
 * 
 *     if slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
 *         memcpy(result, src.data, size)
 *     else:
 */
    goto __pyx_L9;
  }

  /* "View.MemoryView":1201
 *         memcpy(result, src.data, size)
 *     else:
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
  /*else*/ {
    copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
  }
  __pyx_L9:;

  /* "View.MemoryView":1203
 *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  /* "View.MemoryView":1165
 * 
 * @cname('__pyx_memoryview_copy_data_to_temp')
 * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
 *                              __Pyx_memviewslice *tmpslice,
 *                              char order,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = NULL;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1208
 * 
 * @cname('__pyx_memoryview_err_extents')
 * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 */

static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
  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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err_extents", 0);

  /* "View.MemoryView":1211
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 *                                                         (i, extent1, extent2))             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_err_dim')
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;

  /* "View.MemoryView":1210
 * cdef int _err_extents(int i, Py_ssize_t extent1,
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %             # <<<<<<<<<<<<<<
 *                                                         (i, extent1, extent2))
 * 
 */
  __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1210; __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[4]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__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[4]; __pyx_lineno = 1210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":1208
 * 
 * @cname('__pyx_memoryview_err_extents')
 * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
 *                              Py_ssize_t extent2) except -1 with gil:
 *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
 */

  /* function exit code */
  __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("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1214
 * 
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
 *     raise error(msg.decode('ascii') % dim)
 * 
 */

static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
  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;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err_dim", 0);
  __Pyx_INCREF(__pyx_v_error);

  /* "View.MemoryView":1215
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
 *     raise error(msg.decode('ascii') % dim)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_err')
 */
  __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_error);
  __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__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[4]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":1214
 * 
 * @cname('__pyx_memoryview_err_dim')
 * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
 *     raise error(msg.decode('ascii') % dim)
 * 
 */

  /* function exit code */
  __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("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1218
 * 
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))
 */

static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
  int __pyx_r;
  __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;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_err", 0);
  __Pyx_INCREF(__pyx_v_error);

  /* "View.MemoryView":1219
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:
 *     if msg != NULL:             # <<<<<<<<<<<<<<
 *         raise error(msg.decode('ascii'))
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1220
 * cdef int _err(object error, char *msg) except -1 with gil:
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))             # <<<<<<<<<<<<<<
 *     else:
 *         raise error
 */
    __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_error);
    __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":1219
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:
 *     if msg != NULL:             # <<<<<<<<<<<<<<
 *         raise error(msg.decode('ascii'))
 *     else:
 */
  }

  /* "View.MemoryView":1222
 *         raise error(msg.decode('ascii'))
 *     else:
 *         raise error             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_copy_contents')
 */
  /*else*/ {
    __Pyx_Raise(__pyx_v_error, 0, 0, 0);
    {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "View.MemoryView":1218
 * 
 * @cname('__pyx_memoryview_err')
 * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
 *     if msg != NULL:
 *         raise error(msg.decode('ascii'))
 */

  /* function exit code */
  __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("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
  return __pyx_r;
}

/* "View.MemoryView":1225
 * 
 * @cname('__pyx_memoryview_copy_contents')
 * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice dst,
 *                                   int src_ndim, int dst_ndim,
 */

static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) {
  void *__pyx_v_tmpdata;
  size_t __pyx_v_itemsize;
  int __pyx_v_i;
  char __pyx_v_order;
  int __pyx_v_broadcasting;
  int __pyx_v_direct_copy;
  __Pyx_memviewslice __pyx_v_tmp;
  int __pyx_v_ndim;
  int __pyx_r;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  void *__pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "View.MemoryView":1233
 *     Check for overlapping memory and verify the shapes.
 *     """
 *     cdef void *tmpdata = NULL             # <<<<<<<<<<<<<<
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef int i
 */
  __pyx_v_tmpdata = NULL;

  /* "View.MemoryView":1234
 *     """
 *     cdef void *tmpdata = NULL
 *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)
 */
  __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
  __pyx_v_itemsize = __pyx_t_1;

  /* "View.MemoryView":1236
 *     cdef size_t itemsize = src.memview.view.itemsize
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)             # <<<<<<<<<<<<<<
 *     cdef bint broadcasting = False
 *     cdef bint direct_copy = False
 */
  __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);

  /* "View.MemoryView":1237
 *     cdef int i
 *     cdef char order = get_best_order(&src, src_ndim)
 *     cdef bint broadcasting = False             # <<<<<<<<<<<<<<
 *     cdef bint direct_copy = False
 *     cdef __Pyx_memviewslice tmp
 */
  __pyx_v_broadcasting = 0;

  /* "View.MemoryView":1238
 *     cdef char order = get_best_order(&src, src_ndim)
 *     cdef bint broadcasting = False
 *     cdef bint direct_copy = False             # <<<<<<<<<<<<<<
 *     cdef __Pyx_memviewslice tmp
 * 
 */
  __pyx_v_direct_copy = 0;

  /* "View.MemoryView":1241
 *     cdef __Pyx_memviewslice tmp
 * 
 *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:
 */
  __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1242
 * 
 *     if src_ndim < dst_ndim:
 *         broadcast_leading(&src, src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
 *     elif dst_ndim < src_ndim:
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 */
    __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);

    /* "View.MemoryView":1241
 *     cdef __Pyx_memviewslice tmp
 * 
 *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1243
 *     if src_ndim < dst_ndim:
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 * 
 */
  __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1244
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:
 *         broadcast_leading(&dst, dst_ndim, src_ndim)             # <<<<<<<<<<<<<<
 * 
 *     cdef int ndim = max(src_ndim, dst_ndim)
 */
    __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);

    /* "View.MemoryView":1243
 *     if src_ndim < dst_ndim:
 *         broadcast_leading(&src, src_ndim, dst_ndim)
 *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 * 
 */
  }
  __pyx_L3:;

  /* "View.MemoryView":1246
 *         broadcast_leading(&dst, dst_ndim, src_ndim)
 * 
 *     cdef int ndim = max(src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim):
 */
  __pyx_t_3 = __pyx_v_dst_ndim;
  __pyx_t_4 = __pyx_v_src_ndim;
  if (((__pyx_t_3 > __pyx_t_4) != 0)) {
    __pyx_t_5 = __pyx_t_3;
  } else {
    __pyx_t_5 = __pyx_t_4;
  }
  __pyx_v_ndim = __pyx_t_5;

  /* "View.MemoryView":1248
 *     cdef int ndim = max(src_ndim, dst_ndim)
 * 
 *     for i in range(ndim):             # <<<<<<<<<<<<<<
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:
 */
  __pyx_t_5 = __pyx_v_ndim;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "View.MemoryView":1249
 * 
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 */
    __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1250
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
 *                 broadcasting = True
 *                 src.strides[i] = 0
 */
      __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
      if (__pyx_t_2) {

        /* "View.MemoryView":1251
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:
 *                 broadcasting = True             # <<<<<<<<<<<<<<
 *                 src.strides[i] = 0
 *             else:
 */
        __pyx_v_broadcasting = 1;

        /* "View.MemoryView":1252
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 *                 src.strides[i] = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 _err_extents(i, dst.shape[i], src.shape[i])
 */
        (__pyx_v_src.strides[__pyx_v_i]) = 0;

        /* "View.MemoryView":1250
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:
 *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
 *                 broadcasting = True
 *                 src.strides[i] = 0
 */
        goto __pyx_L7;
      }

      /* "View.MemoryView":1254
 *                 src.strides[i] = 0
 *             else:
 *                 _err_extents(i, dst.shape[i], src.shape[i])             # <<<<<<<<<<<<<<
 * 
 *         if src.suboffsets[i] >= 0:
 */
      /*else*/ {
        __pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L7:;

      /* "View.MemoryView":1249
 * 
 *     for i in range(ndim):
 *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
 *             if src.shape[i] == 1:
 *                 broadcasting = True
 */
    }

    /* "View.MemoryView":1256
 *                 _err_extents(i, dst.shape[i], src.shape[i])
 * 
 *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 */
    __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1257
 * 
 *         if src.suboffsets[i] >= 0:
 *             _err_dim(ValueError, "Dimension %d is not direct", i)             # <<<<<<<<<<<<<<
 * 
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 */
      __pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Dimension_d_is_not_direct, __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "View.MemoryView":1256
 *                 _err_extents(i, dst.shape[i], src.shape[i])
 * 
 *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 */
    }
  }

  /* "View.MemoryView":1259
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
 * 
 *         if not slice_is_contig(&src, order, ndim):
 */
  __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1261
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 * 
 *         if not slice_is_contig(&src, order, ndim):             # <<<<<<<<<<<<<<
 *             order = get_best_order(&dst, ndim)
 * 
 */
    __pyx_t_2 = ((!(__pyx_memviewslice_is_contig((&__pyx_v_src), __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1262
 * 
 *         if not slice_is_contig(&src, order, ndim):
 *             order = get_best_order(&dst, ndim)             # <<<<<<<<<<<<<<
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
 */
      __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);

      /* "View.MemoryView":1261
 *     if slices_overlap(&src, &dst, ndim, itemsize):
 * 
 *         if not slice_is_contig(&src, order, ndim):             # <<<<<<<<<<<<<<
 *             order = get_best_order(&dst, ndim)
 * 
 */
    }

    /* "View.MemoryView":1264
 *             order = get_best_order(&dst, ndim)
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)             # <<<<<<<<<<<<<<
 *         src = tmp
 * 
 */
    __pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_tmpdata = __pyx_t_6;

    /* "View.MemoryView":1265
 * 
 *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
 *         src = tmp             # <<<<<<<<<<<<<<
 * 
 *     if not broadcasting:
 */
    __pyx_v_src = __pyx_v_tmp;

    /* "View.MemoryView":1259
 *             _err_dim(ValueError, "Dimension %d is not direct", i)
 * 
 *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
 * 
 *         if not slice_is_contig(&src, order, ndim):
 */
  }

  /* "View.MemoryView":1267
 *         src = tmp
 * 
 *     if not broadcasting:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
  if (__pyx_t_2) {

    /* "View.MemoryView":1270
 * 
 * 
 *         if slice_is_contig(&src, 'C', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)
 *         elif slice_is_contig(&src, 'F', ndim):
 */
    __pyx_t_2 = (__pyx_memviewslice_is_contig((&__pyx_v_src), 'C', __pyx_v_ndim) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1271
 * 
 *         if slice_is_contig(&src, 'C', ndim):
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)             # <<<<<<<<<<<<<<
 *         elif slice_is_contig(&src, 'F', ndim):
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)
 */
      __pyx_v_direct_copy = __pyx_memviewslice_is_contig((&__pyx_v_dst), 'C', __pyx_v_ndim);

      /* "View.MemoryView":1270
 * 
 * 
 *         if slice_is_contig(&src, 'C', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)
 *         elif slice_is_contig(&src, 'F', ndim):
 */
      goto __pyx_L12;
    }

    /* "View.MemoryView":1272
 *         if slice_is_contig(&src, 'C', ndim):
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)
 *         elif slice_is_contig(&src, 'F', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)
 * 
 */
    __pyx_t_2 = (__pyx_memviewslice_is_contig((&__pyx_v_src), 'F', __pyx_v_ndim) != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1273
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)
 *         elif slice_is_contig(&src, 'F', ndim):
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)             # <<<<<<<<<<<<<<
 * 
 *         if direct_copy:
 */
      __pyx_v_direct_copy = __pyx_memviewslice_is_contig((&__pyx_v_dst), 'F', __pyx_v_ndim);

      /* "View.MemoryView":1272
 *         if slice_is_contig(&src, 'C', ndim):
 *             direct_copy = slice_is_contig(&dst, 'C', ndim)
 *         elif slice_is_contig(&src, 'F', ndim):             # <<<<<<<<<<<<<<
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)
 * 
 */
    }
    __pyx_L12:;

    /* "View.MemoryView":1275
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)
 * 
 *         if direct_copy:             # <<<<<<<<<<<<<<
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    __pyx_t_2 = (__pyx_v_direct_copy != 0);
    if (__pyx_t_2) {

      /* "View.MemoryView":1277
 *         if direct_copy:
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 */
      __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

      /* "View.MemoryView":1278
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))             # <<<<<<<<<<<<<<
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)
 */
      memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim));

      /* "View.MemoryView":1279
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 *             free(tmpdata)
 *             return 0
 */
      __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

      /* "View.MemoryView":1280
 *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)             # <<<<<<<<<<<<<<
 *             return 0
 * 
 */
      free(__pyx_v_tmpdata);

      /* "View.MemoryView":1281
 *             refcount_copying(&dst, dtype_is_object, ndim, True)
 *             free(tmpdata)
 *             return 0             # <<<<<<<<<<<<<<
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "View.MemoryView":1275
 *             direct_copy = slice_is_contig(&dst, 'F', ndim)
 * 
 *         if direct_copy:             # <<<<<<<<<<<<<<
 * 
 *             refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    }

    /* "View.MemoryView":1267
 *         src = tmp
 * 
 *     if not broadcasting:             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":1283
 *             return 0
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = (__pyx_v_order == 'F');
  if (__pyx_t_2) {
    __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
  }
  __pyx_t_7 = (__pyx_t_2 != 0);
  if (__pyx_t_7) {

    /* "View.MemoryView":1286
 * 
 * 
 *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
 *         transpose_memslice(&dst)
 * 
 */
    __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":1287
 * 
 *         transpose_memslice(&src)
 *         transpose_memslice(&dst)             # <<<<<<<<<<<<<<
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 */
    __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "View.MemoryView":1283
 *             return 0
 * 
 *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
 * 
 * 
 */
  }

  /* "View.MemoryView":1289
 *         transpose_memslice(&dst)
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 */
  __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

  /* "View.MemoryView":1290
 * 
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)             # <<<<<<<<<<<<<<
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 * 
 */
  copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);

  /* "View.MemoryView":1291
 *     refcount_copying(&dst, dtype_is_object, ndim, False)
 *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
 *     refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 * 
 *     free(tmpdata)
 */
  __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

  /* "View.MemoryView":1293
 *     refcount_copying(&dst, dtype_is_object, ndim, True)
 * 
 *     free(tmpdata)             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
  free(__pyx_v_tmpdata);

  /* "View.MemoryView":1294
 * 
 *     free(tmpdata)
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "View.MemoryView":1225
 * 
 * @cname('__pyx_memoryview_copy_contents')
 * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
 *                                   __Pyx_memviewslice dst,
 *                                   int src_ndim, int dst_ndim,
 */

  /* function exit code */
  __pyx_L1_error:;
  {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
  }
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

/* "View.MemoryView":1297
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
 *                             int ndim,
 *                             int ndim_other) nogil:
 */

static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
  int __pyx_v_i;
  int __pyx_v_offset;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "View.MemoryView":1301
 *                             int ndim_other) nogil:
 *     cdef int i
 *     cdef int offset = ndim_other - ndim             # <<<<<<<<<<<<<<
 * 
 *     for i in range(ndim - 1, -1, -1):
 */
  __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);

  /* "View.MemoryView":1303
 *     cdef int offset = ndim_other - ndim
 * 
 *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
 *         mslice.shape[i + offset] = mslice.shape[i]
 *         mslice.strides[i + offset] = mslice.strides[i]
 */
  for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) {
    __pyx_v_i = __pyx_t_1;

    /* "View.MemoryView":1304
 * 
 *     for i in range(ndim - 1, -1, -1):
 *         mslice.shape[i + offset] = mslice.shape[i]             # <<<<<<<<<<<<<<
 *         mslice.strides[i + offset] = mslice.strides[i]
 *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
 */
    (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);

    /* "View.MemoryView":1305
 *     for i in range(ndim - 1, -1, -1):
 *         mslice.shape[i + offset] = mslice.shape[i]
 *         mslice.strides[i + offset] = mslice.strides[i]             # <<<<<<<<<<<<<<
 *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
 * 
 */
    (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);

    /* "View.MemoryView":1306
 *         mslice.shape[i + offset] = mslice.shape[i]
 *         mslice.strides[i + offset] = mslice.strides[i]
 *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]             # <<<<<<<<<<<<<<
 * 
 *     for i in range(offset):
 */
    (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
  }

  /* "View.MemoryView":1308
 *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
 * 
 *     for i in range(offset):             # <<<<<<<<<<<<<<
 *         mslice.shape[i] = 1
 *         mslice.strides[i] = mslice.strides[0]
 */
  __pyx_t_1 = __pyx_v_offset;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "View.MemoryView":1309
 * 
 *     for i in range(offset):
 *         mslice.shape[i] = 1             # <<<<<<<<<<<<<<
 *         mslice.strides[i] = mslice.strides[0]
 *         mslice.suboffsets[i] = -1
 */
    (__pyx_v_mslice->shape[__pyx_v_i]) = 1;

    /* "View.MemoryView":1310
 *     for i in range(offset):
 *         mslice.shape[i] = 1
 *         mslice.strides[i] = mslice.strides[0]             # <<<<<<<<<<<<<<
 *         mslice.suboffsets[i] = -1
 * 
 */
    (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);

    /* "View.MemoryView":1311
 *         mslice.shape[i] = 1
 *         mslice.strides[i] = mslice.strides[0]
 *         mslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
 * 
 * 
 */
    (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
  }

  /* "View.MemoryView":1297
 * 
 * @cname('__pyx_memoryview_broadcast_leading')
 * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
 *                             int ndim,
 *                             int ndim_other) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1319
 * 
 * @cname('__pyx_memoryview_refcount_copying')
 * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
 *                            int ndim, bint inc) nogil:
 * 
 */

static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) {
  int __pyx_t_1;

  /* "View.MemoryView":1323
 * 
 * 
 *     if dtype_is_object:             # <<<<<<<<<<<<<<
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
 *                                            dst.strides, ndim, inc)
 */
  __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1324
 * 
 *     if dtype_is_object:
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,             # <<<<<<<<<<<<<<
 *                                            dst.strides, ndim, inc)
 * 
 */
    __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc);

    /* "View.MemoryView":1323
 * 
 * 
 *     if dtype_is_object:             # <<<<<<<<<<<<<<
 *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
 *                                            dst.strides, ndim, inc)
 */
  }

  /* "View.MemoryView":1319
 * 
 * @cname('__pyx_memoryview_refcount_copying')
 * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
 *                            int ndim, bint inc) nogil:
 * 
 */

  /* function exit code */
}

/* "View.MemoryView":1328
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
 * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 */

static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
  __Pyx_RefNannyDeclarations
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);

  /* "View.MemoryView":1331
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 *     refcount_objects_in_slice(data, shape, strides, ndim, inc)             # <<<<<<<<<<<<<<
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 */
  __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);

  /* "View.MemoryView":1328
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
 * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                              Py_ssize_t *strides, int ndim,
 *                                              bint inc) with gil:
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "View.MemoryView":1334
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                     Py_ssize_t *strides, int ndim, bint inc):
 *     cdef Py_ssize_t i
 */

static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);

  /* "View.MemoryView":1338
 *     cdef Py_ssize_t i
 * 
 *     for i in range(shape[0]):             # <<<<<<<<<<<<<<
 *         if ndim == 1:
 *             if inc:
 */
  __pyx_t_1 = (__pyx_v_shape[0]);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "View.MemoryView":1339
 * 
 *     for i in range(shape[0]):
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])
 */
    __pyx_t_3 = ((__pyx_v_ndim == 1) != 0);
    if (__pyx_t_3) {

      /* "View.MemoryView":1340
 *     for i in range(shape[0]):
 *         if ndim == 1:
 *             if inc:             # <<<<<<<<<<<<<<
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 */
      __pyx_t_3 = (__pyx_v_inc != 0);
      if (__pyx_t_3) {

        /* "View.MemoryView":1341
 *         if ndim == 1:
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
 *             else:
 *                 Py_DECREF((<PyObject **> data)[0])
 */
        Py_INCREF((((PyObject **)__pyx_v_data)[0]));

        /* "View.MemoryView":1340
 *     for i in range(shape[0]):
 *         if ndim == 1:
 *             if inc:             # <<<<<<<<<<<<<<
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 */
        goto __pyx_L6;
      }

      /* "View.MemoryView":1343
 *                 Py_INCREF((<PyObject **> data)[0])
 *             else:
 *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,
 */
      /*else*/ {
        Py_DECREF((((PyObject **)__pyx_v_data)[0]));
      }
      __pyx_L6:;

      /* "View.MemoryView":1339
 * 
 *     for i in range(shape[0]):
 *         if ndim == 1:             # <<<<<<<<<<<<<<
 *             if inc:
 *                 Py_INCREF((<PyObject **> data)[0])
 */
      goto __pyx_L5;
    }

    /* "View.MemoryView":1345
 *                 Py_DECREF((<PyObject **> data)[0])
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
 *                                       ndim - 1, inc)
 * 
 */
    /*else*/ {

      /* "View.MemoryView":1346
 *         else:
 *             refcount_objects_in_slice(data, shape + 1, strides + 1,
 *                                       ndim - 1, inc)             # <<<<<<<<<<<<<<
 * 
 *         data += strides[0]
 */
      __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
    }
    __pyx_L5:;

    /* "View.MemoryView":1348
 *                                       ndim - 1, inc)
 * 
 *         data += strides[0]             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
  }

  /* "View.MemoryView":1334
 * 
 * @cname('__pyx_memoryview_refcount_objects_in_slice')
 * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                                     Py_ssize_t *strides, int ndim, bint inc):
 *     cdef Py_ssize_t i
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

/* "View.MemoryView":1354
 * 
 * @cname('__pyx_memoryview_slice_assign_scalar')
 * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 */

static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) {

  /* "View.MemoryView":1357
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 *     refcount_copying(dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
 *                          itemsize, item)
 */
  __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);

  /* "View.MemoryView":1358
 *                               bint dtype_is_object) nogil:
 *     refcount_copying(dst, dtype_is_object, ndim, False)
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,             # <<<<<<<<<<<<<<
 *                          itemsize, item)
 *     refcount_copying(dst, dtype_is_object, ndim, True)
 */
  __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item);

  /* "View.MemoryView":1360
 *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
 *                          itemsize, item)
 *     refcount_copying(dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);

  /* "View.MemoryView":1354
 * 
 * @cname('__pyx_memoryview_slice_assign_scalar')
 * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
 *                               size_t itemsize, void *item,
 *                               bint dtype_is_object) nogil:
 */

  /* function exit code */
}

/* "View.MemoryView":1364
 * 
 * @cname('__pyx_memoryview__slice_assign_scalar')
 * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                               Py_ssize_t *strides, int ndim,
 *                               size_t itemsize, void *item) nogil:
 */

static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) {
  CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_stride;
  Py_ssize_t __pyx_v_extent;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;

  /* "View.MemoryView":1368
 *                               size_t itemsize, void *item) nogil:
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t stride = strides[0]             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t extent = shape[0]
 * 
 */
  __pyx_v_stride = (__pyx_v_strides[0]);

  /* "View.MemoryView":1369
 *     cdef Py_ssize_t i
 *     cdef Py_ssize_t stride = strides[0]
 *     cdef Py_ssize_t extent = shape[0]             # <<<<<<<<<<<<<<
 * 
 *     if ndim == 1:
 */
  __pyx_v_extent = (__pyx_v_shape[0]);

  /* "View.MemoryView":1371
 *     cdef Py_ssize_t extent = shape[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 */
  __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
  if (__pyx_t_1) {

    /* "View.MemoryView":1372
 * 
 *     if ndim == 1:
 *         for i in range(extent):             # <<<<<<<<<<<<<<
 *             memcpy(data, item, itemsize)
 *             data += stride
 */
    __pyx_t_2 = __pyx_v_extent;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "View.MemoryView":1373
 *     if ndim == 1:
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)             # <<<<<<<<<<<<<<
 *             data += stride
 *     else:
 */
      memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize);

      /* "View.MemoryView":1374
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 *             data += stride             # <<<<<<<<<<<<<<
 *     else:
 *         for i in range(extent):
 */
      __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
    }

    /* "View.MemoryView":1371
 *     cdef Py_ssize_t extent = shape[0]
 * 
 *     if ndim == 1:             # <<<<<<<<<<<<<<
 *         for i in range(extent):
 *             memcpy(data, item, itemsize)
 */
    goto __pyx_L3;
  }

  /* "View.MemoryView":1376
 *             data += stride
 *     else:
 *         for i in range(extent):             # <<<<<<<<<<<<<<
 *             _slice_assign_scalar(data, shape + 1, strides + 1,
 *                                 ndim - 1, itemsize, item)
 */
  /*else*/ {
    __pyx_t_2 = __pyx_v_extent;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "View.MemoryView":1377
 *     else:
 *         for i in range(extent):
 *             _slice_assign_scalar(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
 *                                 ndim - 1, itemsize, item)
 *             data += stride
 */
      __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item);

      /* "View.MemoryView":1379
 *             _slice_assign_scalar(data, shape + 1, strides + 1,
 *                                 ndim - 1, itemsize, item)
 *             data += stride             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
    }
  }
  __pyx_L3:;

  /* "View.MemoryView":1364
 * 
 * @cname('__pyx_memoryview__slice_assign_scalar')
 * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                               Py_ssize_t *strides, int ndim,
 *                               size_t itemsize, void *item) nogil:
 */

  /* function exit code */
}
static struct __pyx_vtabstruct_7plastid_8genomics_8roitools_GenomicSegment __pyx_vtable_7plastid_8genomics_8roitools_GenomicSegment;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools_GenomicSegment(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)o);
  p->__pyx_vtab = __pyx_vtabptr_7plastid_8genomics_8roitools_GenomicSegment;
  p->chrom = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools_GenomicSegment(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *p = (struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  Py_CLEAR(p->chrom);
  (*Py_TYPE(o)->tp_free)(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_start(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5start_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_end(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_3end_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_chrom(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5chrom_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_strand(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_6strand_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_c_strand(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_8c_strand_1__get__(o);
}

static PyMethodDef __pyx_methods_7plastid_8genomics_8roitools_GenomicSegment[] = {
  {"__reduce__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_3__reduce__, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_2__reduce__},
  {"from_str", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_9from_str, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_8from_str},
  {"__copy__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_11__copy__, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_10__copy__},
  {"__deepcopy__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_13__deepcopy__, METH_O, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_12__deepcopy__},
  {"_cmp_helper", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_19_cmp_helper, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_18_cmp_helper},
  {"contains", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_23contains, METH_O, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_22contains},
  {"overlaps", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_25overlaps, METH_O, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_24overlaps},
  {"as_igv_str", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_27as_igv_str, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_26as_igv_str},
  {"from_igv_str", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_29from_igv_str, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_28from_igv_str},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_7plastid_8genomics_8roitools_GenomicSegment[] = {
  {(char *)"start", __pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_start, 0, __pyx_k_Zero_indexed_Pythonic_start_coor, 0},
  {(char *)"end", __pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_end, 0, __pyx_k_Zero_indexed_half_open_Pythonic, 0},
  {(char *)"chrom", __pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_chrom, 0, __pyx_k_Chromosome_where_GenomicSegment, 0},
  {(char *)"strand", __pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_strand, 0, __pyx_k_Strand_of_GenomicSegment_for_for, 0},
  {(char *)"c_strand", __pyx_getprop_7plastid_8genomics_8roitools_14GenomicSegment_c_strand, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_GenomicSegment = {
  __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_15__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_21__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_GenomicSegment = {
  __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_15__len__, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_7plastid_8genomics_8roitools_GenomicSegment = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.GenomicSegment", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools_GenomicSegment, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_5__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_GenomicSegment, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_GenomicSegment, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_7__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "A continuous segment of the genome, defined by a chromosome name,\n    a start coordinate, and end coordinate, and a strand. Building block\n    for a |SegmentChain| or a |Transcript|.\n\n    Attributes\n    ----------\n    chrom : str\n        Name of chromosome\n\n    start : int\n        0-indexed, left most position of segment\n\n    end : int\n        0-indexed, half-open right most position of segment\n\n    strand : str\n        Chromosome strand (`'+'`, `'-'`, or `'.'`)\n   \n\n    Examples\n    --------\n\n    |GenomicSegments| sort lexically by chromosome, start position, end position,\n    and finally strand::\n        \n        >>> GenomicSegment(\"chrA\",50,100,\"+\") < GenomicSegment(\"chrB\",0,10,\"+\")\n        True\n\n        >>> GenomicSegment(\"chrA\",50,100,\"+\") < GenomicSegment(\"chrA\",75,100,\"+\")\n        True\n\n        >>> GenomicSegment(\"chrA\",50,100,\"+\") < GenomicSegment(\"chrA\",55,75,\"+\")\n        True\n\n        >>> GenomicSegment(\"chrA\",50,100,\"+\") < GenomicSegment(\"chrA\",50,150,\"+\")\n        True\n\n        >>> GenomicSegment(\"chrA\",50,100,\"+\") < GenomicSegment(\"chrA\",50,100,\"-\")\n        True\n\n\n    They also provide a few convenience methods for containment or overlap. To be\n    contained, a segment must be on the same chromosome and strand as its container,\n    and its coordinates must be within or equal to its endpoints\n\n        >>> GenomicSegment(\"chrA\",50,100,\"+\") in GenomicSegment(\"chrA\",25,100,\"+\")\n        True\n\n        >>> GenomicSegment(\"chrA\",50,100,\"+\") in GenomicSegment(\"chrA\",50,100,\"+\")\n        True\n       \n        >>> GenomicSegment(\"chrA\",50,100,\"+\") in GenomicSegment(\"chrA\",25,100,\"-\")\n        False\n\n        >>> GenomicSegment(\"chrA\",50,100,\"+\") in GenomicSegment(\"chrA\",75,200,\"+\")\n        False\n\n\n    Similarly, to overlap, |GenomicSegments| must be on the same strand and \n    chromosome.\n     \n    See also\n    --------\n    SegmentChain\n        Base class for genomic features, built from multiple |GenomicSegments|\n\n    Transcript\n        Subclass of |SegmentChain| that adds convenience methods for manipulating\n        coding regions, UTRs, et c\n    ", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  __pyx_pw_7plastid_8genomics_8roitools_14GenomicSegment_17__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_7plastid_8genomics_8roitools_GenomicSegment, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_7plastid_8genomics_8roitools_GenomicSegment, /*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_7plastid_8genomics_8roitools_GenomicSegment, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools_SegmentChain(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)o);
  p->__pyx_vtab = __pyx_vtabptr_7plastid_8genomics_8roitools_SegmentChain;
  p->_segments = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_mask_segments = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->spanning_segment = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)Py_None); Py_INCREF(Py_None);
  p->_position_hash = ((arrayobject *)Py_None); Py_INCREF(Py_None);
  p->_position_mask = ((arrayobject *)Py_None); Py_INCREF(Py_None);
  p->attr = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_inverse_hash = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools_SegmentChain(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *p = (struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_segments);
  Py_CLEAR(p->_mask_segments);
  Py_CLEAR(p->spanning_segment);
  Py_CLEAR(p->_position_hash);
  Py_CLEAR(p->_position_mask);
  Py_CLEAR(p->attr);
  Py_CLEAR(p->_inverse_hash);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools_SegmentChain(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *p = (struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)o;
  if (p->_segments) {
    e = (*v)(p->_segments, a); if (e) return e;
  }
  if (p->_mask_segments) {
    e = (*v)(p->_mask_segments, a); if (e) return e;
  }
  if (p->spanning_segment) {
    e = (*v)(((PyObject*)p->spanning_segment), a); if (e) return e;
  }
  if (p->_position_hash) {
    e = (*v)(((PyObject*)p->_position_hash), a); if (e) return e;
  }
  if (p->_position_mask) {
    e = (*v)(((PyObject*)p->_position_mask), a); if (e) return e;
  }
  if (p->attr) {
    e = (*v)(p->attr, a); if (e) return e;
  }
  if (p->_inverse_hash) {
    e = (*v)(p->_inverse_hash, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7plastid_8genomics_8roitools_SegmentChain(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *p = (struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *)o;
  tmp = ((PyObject*)p->_segments);
  p->_segments = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_mask_segments);
  p->_mask_segments = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->spanning_segment);
  p->spanning_segment = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_position_hash);
  p->_position_hash = ((arrayobject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_position_mask);
  p->_position_mask = ((arrayobject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->attr);
  p->attr = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_inverse_hash);
  p->_inverse_hash = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_7plastid_8genomics_8roitools_SegmentChain(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 PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_chrom(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_5chrom_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_strand(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_6strand_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_c_strand(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_8c_strand_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_segments(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_8segments_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_mask_segments(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13mask_segments_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_spanning_segment(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_16spanning_segment_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_length(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_6length_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_masked_length(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13masked_length_1__get__(o);
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_attr(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_1__get__(o);
}

static int __pyx_setprop_7plastid_8genomics_8roitools_12SegmentChain_attr(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_3__set__(o, v);
  }
  else {
    return __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_4attr_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_7plastid_8genomics_8roitools_SegmentChain[] = {
  {"sort", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_3sort, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_2sort},
  {"__reduce__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_5__reduce__, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_4__reduce__},
  {"__getstate__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_7__getstate__, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_6__getstate__},
  {"__setstate__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_9__setstate__, METH_O, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_8__setstate__},
  {"__copy__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_11__copy__, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_10__copy__},
  {"__deepcopy__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_13__deepcopy__, METH_O, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_12__deepcopy__},
  {"__next__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_25__next__, METH_NOARGS|METH_COEXIST, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_24__next__},
  {"next", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_27next, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_26next},
  {"shares_segments_with", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_33shares_segments_with, METH_O, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_32shares_segments_with},
  {"unstranded_overlaps", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_35unstranded_overlaps, METH_O, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_34unstranded_overlaps},
  {"overlaps", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_37overlaps, METH_O, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_36overlaps},
  {"antisense_overlaps", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_39antisense_overlaps, METH_O, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_38antisense_overlaps},
  {"covers", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_41covers, METH_O, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_40covers},
  {"get_antisense", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_43get_antisense, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_42get_antisense},
  {"get_position_list", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_45get_position_list, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_44get_position_list},
  {"get_position_set", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_47get_position_set, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_46get_position_set},
  {"get_masked_position_set", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_49get_masked_position_set, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_48get_masked_position_set},
  {"get_name", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_51get_name, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_50get_name},
  {"get_gene", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_53get_gene, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_52get_gene},
  {"get_length", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_55get_length, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_54get_length},
  {"get_masked_length", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_57get_masked_length, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_56get_masked_length},
  {"add_segments", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_59add_segments, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_58add_segments},
  {"add_masks", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_61add_masks, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_60add_masks},
  {"get_masks", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_63get_masks, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_62get_masks},
  {"get_masks_as_segmentchain", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_65get_masks_as_segmentchain, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_64get_masks_as_segmentchain},
  {"reset_masks", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_67reset_masks, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_66reset_masks},
  {"get_junctions", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_69get_junctions, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_68get_junctions},
  {"as_gff3", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_71as_gff3, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_70as_gff3},
  {"as_gtf", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_73as_gtf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_72as_gtf},
  {"_get_8_gff_columns", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_75_get_8_gff_columns, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_74_get_8_gff_columns},
  {"as_bed", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_77as_bed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_76as_bed},
  {"as_psl", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_79as_psl, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_78as_psl},
  {"get_segmentchain_coordinate", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_81get_segmentchain_coordinate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_80get_segmentchain_coordinate},
  {"get_genomic_coordinate", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_83get_genomic_coordinate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_82get_genomic_coordinate},
  {"get_subchain", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_85get_subchain, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_84get_subchain},
  {"get_counts", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_87get_counts, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_86get_counts},
  {"get_masked_counts", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_89get_masked_counts, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_88get_masked_counts},
  {"get_sequence", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_91get_sequence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_90get_sequence},
  {"get_fasta", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_93get_fasta, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_92get_fasta},
  {"from_str", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_95from_str, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_94from_str},
  {"from_bed", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_97from_bed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_96from_bed},
  {"from_psl", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_99from_psl, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_98from_psl},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_7plastid_8genomics_8roitools_SegmentChain[] = {
  {(char *)"chrom", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_chrom, 0, __pyx_k_Chromosome_the_SegmentChain_resi, 0},
  {(char *)"strand", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_strand, 0, __pyx_k_Strand_of_the_SegmentChain, 0},
  {(char *)"c_strand", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_c_strand, 0, 0, 0},
  {(char *)"segments", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_segments, 0, __pyx_k_Copy_of_list_of_GenomicSegments, 0},
  {(char *)"mask_segments", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_mask_segments, 0, __pyx_k_Copy_of_list_of_GenomicSegments_2, 0},
  {(char *)"spanning_segment", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_spanning_segment, 0, 0, 0},
  {(char *)"length", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_length, 0, 0, 0},
  {(char *)"masked_length", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_masked_length, 0, 0, 0},
  {(char *)"attr", __pyx_getprop_7plastid_8genomics_8roitools_12SegmentChain_attr, __pyx_setprop_7plastid_8genomics_8roitools_12SegmentChain_attr, __pyx_k_attr_dict, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_SegmentChain = {
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_29__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_7plastid_8genomics_8roitools_SegmentChain, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_31__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SegmentChain = {
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_29__len__, /*mp_length*/
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_21__getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyTypeObject __pyx_type_7plastid_8genomics_8roitools_SegmentChain = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.SegmentChain", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools_SegmentChain, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_17__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_SegmentChain, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SegmentChain, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_19__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Base class for genomic features. |SegmentChains| can contain zero or more\n    |GenomicSegments|, and therefore can model discontinuous, features -- such\n    as multi-exon transcripts or gapped alignments -- in addition,\n    to continuous features.\n    \n    Numerous convenience functions are supplied for:\n    \n      - converting between coordinates relative to the genome and relative\n        to the internal coordinates of a spliced |SegmentChain|\n        \n      - fetching genomic sequence, read alignments, or count data, accounting\n        for splicing of the segments, and, in the case of reverse-strand features,\n        reverse-complementing\n      \n      - slicing or fetching sub-regions of a |SegmentChain|\n      \n      - testing equality, inequality, overlap, containment, coverage of, or\n        sharing of segments with other |SegmentChain| or |GenomicSegment| objects\n    \n      - import/export to `BED`_, `PSL`_, `GTF2`_, and `GFF3`_ formats,\n        for use in other software packages or in a genome browser.\n    \n    Intervals are sorted from lowest to greatest starting coordinate on their\n    reference sequence, regardless of strand. Iteration over the SegmentChain\n    will yield intervals from left-to-right in the genome.\n    \n\n    Attributes\n    ----------\n    spanning_segment : |GenomicSegment|\n        A |GenomicSegment| spanning the endpoints of the |SegmentChain|\n\n    strand : str\n        The chromosome strand (`'+'`, `'-'`, or `'.'`)\n\n    chrom : str\n        Name of the chromosome on which the |SegmentChain| resides\n\n    attr : dict\n        Any miscellaneous attributes or annotation data\n\n\n    See Also\n    --------\n\tTranscript\n        Transcript subclass, additionally providing richer `GTF2`_, `GFF3`_,\n        and `BED`_ export, as well as methods for fetching coding regions\n        and UTRs as subsegments\n    ", /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools_SegmentChain, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools_SegmentChain, /*tp_clear*/
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_15__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_23__iter__, /*tp_iter*/
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_25__next__, /*tp_iternext*/
  __pyx_methods_7plastid_8genomics_8roitools_SegmentChain, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_7plastid_8genomics_8roitools_SegmentChain, /*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_7plastid_8genomics_8roitools_SegmentChain, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_7plastid_8genomics_8roitools_Transcript __pyx_vtable_7plastid_8genomics_8roitools_Transcript;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools_Transcript(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *p;
  PyObject *o = __pyx_tp_new_7plastid_8genomics_8roitools_SegmentChain(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_7plastid_8genomics_8roitools_SegmentChain*)__pyx_vtabptr_7plastid_8genomics_8roitools_Transcript;
  p->cds_genome_start = Py_None; Py_INCREF(Py_None);
  p->cds_genome_end = Py_None; Py_INCREF(Py_None);
  p->cds_start = Py_None; Py_INCREF(Py_None);
  p->cds_end = Py_None; Py_INCREF(Py_None);
  if (unlikely(__pyx_pw_7plastid_8genomics_8roitools_10Transcript_1__cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools_Transcript(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *p = (struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->cds_genome_start);
  Py_CLEAR(p->cds_genome_end);
  Py_CLEAR(p->cds_start);
  Py_CLEAR(p->cds_end);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_7plastid_8genomics_8roitools_SegmentChain(o);
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools_Transcript(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *p = (struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)o;
  e = __pyx_tp_traverse_7plastid_8genomics_8roitools_SegmentChain(o, v, a); if (e) return e;
  if (p->cds_genome_start) {
    e = (*v)(p->cds_genome_start, a); if (e) return e;
  }
  if (p->cds_genome_end) {
    e = (*v)(p->cds_genome_end, a); if (e) return e;
  }
  if (p->cds_start) {
    e = (*v)(p->cds_start, a); if (e) return e;
  }
  if (p->cds_end) {
    e = (*v)(p->cds_end, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7plastid_8genomics_8roitools_Transcript(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *p = (struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *)o;
  __pyx_tp_clear_7plastid_8genomics_8roitools_SegmentChain(o);
  tmp = ((PyObject*)p->cds_genome_start);
  p->cds_genome_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->cds_genome_end);
  p->cds_genome_end = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->cds_start);
  p->cds_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->cds_end);
  p->cds_end = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_10Transcript_cds_start(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_10Transcript_9cds_start_1__get__(o);
}

static int __pyx_setprop_7plastid_8genomics_8roitools_10Transcript_cds_start(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7plastid_8genomics_8roitools_10Transcript_9cds_start_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_10Transcript_cds_end(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_10Transcript_7cds_end_1__get__(o);
}

static int __pyx_setprop_7plastid_8genomics_8roitools_10Transcript_cds_end(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7plastid_8genomics_8roitools_10Transcript_7cds_end_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_10Transcript_cds_genome_start(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_1__get__(o);
}

static int __pyx_setprop_7plastid_8genomics_8roitools_10Transcript_cds_genome_start(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7plastid_8genomics_8roitools_10Transcript_16cds_genome_start_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_7plastid_8genomics_8roitools_10Transcript_cds_genome_end(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_1__get__(o);
}

static int __pyx_setprop_7plastid_8genomics_8roitools_10Transcript_cds_genome_end(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_7plastid_8genomics_8roitools_10Transcript_14cds_genome_end_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_7plastid_8genomics_8roitools_Transcript[] = {
  {"__copy__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_3__copy__, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_2__copy__},
  {"__deepcopy__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_5__deepcopy__, METH_O, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_4__deepcopy__},
  {"__reduce__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_7__reduce__, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_6__reduce__},
  {"__getstate__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_9__getstate__, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_8__getstate__},
  {"__setstate__", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_11__setstate__, METH_O, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_10__setstate__},
  {"get_name", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_15get_name, METH_NOARGS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_14get_name},
  {"get_cds", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_17get_cds, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_16get_cds},
  {"get_utr5", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_19get_utr5, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_18get_utr5},
  {"get_utr3", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_21get_utr3, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_20get_utr3},
  {"as_gtf", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_23as_gtf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_22as_gtf},
  {"as_gff3", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_25as_gff3, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_24as_gff3},
  {"as_bed", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_27as_bed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_26as_bed},
  {"from_bed", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_29from_bed, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_28from_bed},
  {"from_psl", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_10Transcript_31from_psl, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_10Transcript_30from_psl},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_7plastid_8genomics_8roitools_Transcript[] = {
  {(char *)"cds_start", __pyx_getprop_7plastid_8genomics_8roitools_10Transcript_cds_start, __pyx_setprop_7plastid_8genomics_8roitools_10Transcript_cds_start, __pyx_k_Start_of_coding_region_relative, 0},
  {(char *)"cds_end", __pyx_getprop_7plastid_8genomics_8roitools_10Transcript_cds_end, __pyx_setprop_7plastid_8genomics_8roitools_10Transcript_cds_end, __pyx_k_End_of_coding_region_relative_to, 0},
  {(char *)"cds_genome_start", __pyx_getprop_7plastid_8genomics_8roitools_10Transcript_cds_genome_start, __pyx_setprop_7plastid_8genomics_8roitools_10Transcript_cds_genome_start, __pyx_k_Starting_coordinate_of_coding_re, 0},
  {(char *)"cds_genome_end", __pyx_getprop_7plastid_8genomics_8roitools_10Transcript_cds_genome_end, __pyx_setprop_7plastid_8genomics_8roitools_10Transcript_cds_genome_end, __pyx_k_Ending_coordinate_of_coding_regi, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_7plastid_8genomics_8roitools_Transcript = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.Transcript", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools_Transcript, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_17__repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_19__str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Subclass of |SegmentChain| specifically for transcripts.\n    In addition to coordinate-conversion, count fetching, sequence fetching,\n    and various other methods inherited from |SegmentChain|, |Transcript|\n    provides convenience methods for fetching sub-chains corresponding to \n    CDS features, 5' UTRs, and 3' UTRs.\n\n\n    Attributes\n    ----------\n    cds_genome_start : int or None\n        Leftmost position in genomic coordinates of coding region, 0-indexed\n\n    cds_genome_end : int or None\n        Rightmost position in genomic coordinates of coding region, 0-indexed\n        and half-open\n\n    cds_start : int or None\n        Stranded position relative to 5' end of transcript at which coding region starts\n        (note: for minus-strand features this will be higher in genomic\n        coordinates than `cds_end`).\n\n    cds_end : int or None\n        Stranded position relative to 5' end of transcript at which coding region ends\n        (note: for minus-strand features this will be lower in genomic coordinates\n        than `cds_start`).\n\n    spanning_segment : |GenomicSegment|\n        A GenomicSegment spanning the endpoints of the Transcript\n\n    strand : str\n        The chromosome strand ('+', '-', or '.')\n\n    chrom : str\n        The chromosome name\n\n    attr : dict\n        Miscellaneous attributes\n    ", /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools_Transcript, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools_Transcript, /*tp_clear*/
  __pyx_pw_7plastid_8genomics_8roitools_10Transcript_13__richcmp__, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_23__iter__, /*tp_iter*/
  #else
  0, /*tp_iter*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_7plastid_8genomics_8roitools_12SegmentChain_25__next__, /*tp_iternext*/
  #else
  0, /*tp_iternext*/
  #endif
  __pyx_methods_7plastid_8genomics_8roitools_Transcript, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_7plastid_8genomics_8roitools_Transcript, /*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_7plastid_8genomics_8roitools_Transcript, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed[8];
static int __pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed = 0;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed)))) {
    o = (PyObject*)__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed[--__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed];
    memset(o, 0, sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_color);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed)))) {
    __pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed[__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed++] = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)o;
  if (p->__pyx_v_color) {
    e = (*v)(p->__pyx_v_color, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)o;
  tmp = ((PyObject*)p->__pyx_v_color);
  p->__pyx_v_color = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.__pyx_scope_struct__as_bed", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr[--__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_X);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr[__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_X) {
    e = (*v)(p->__pyx_v_X, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_X);
  p->__pyx_v_X = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.__pyx_scope_struct_1_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr[8];
static int __pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr = 0;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr)))) {
    o = (PyObject*)__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr[--__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_X);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr)))) {
    __pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr[__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr++] = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_X) {
    e = (*v)(p->__pyx_v_X, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_X);
  p->__pyx_v_X = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.__pyx_scope_struct_2_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr[8];
static int __pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr = 0;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr)))) {
    o = (PyObject*)__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr[--__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_X);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr)))) {
    __pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr[__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr++] = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_X) {
    e = (*v)(p->__pyx_v_X, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_X);
  p->__pyx_v_X = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.__pyx_scope_struct_3_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr[8];
static int __pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr = 0;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr)))) {
    o = (PyObject*)__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr[--__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_X);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr)))) {
    __pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr[__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr++] = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_X) {
    e = (*v)(p->__pyx_v_X, 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_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_X);
  p->__pyx_v_X = 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 PyTypeObject __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.__pyx_scope_struct_4_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl[8];
static int __pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl = 0;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl)))) {
    o = (PyObject*)__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl[--__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl];
    memset(o, 0, sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_ltmp);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl)))) {
    __pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl[__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl++] = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *)o;
  if (p->__pyx_v_ltmp) {
    e = (*v)(p->__pyx_v_ltmp, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *)o;
  tmp = ((PyObject*)p->__pyx_v_ltmp);
  p->__pyx_v_ltmp = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.__pyx_scope_struct_5_as_psl", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr[8];
static int __pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr = 0;

static PyObject *__pyx_tp_new_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr)))) {
    o = (PyObject*)__pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr[--__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr(PyObject *o) {
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_X);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr)))) {
    __pyx_freelist_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr[__pyx_freecount_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr++] = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_X) {
    e = (*v)(p->__pyx_v_X, 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_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_X);
  p->__pyx_v_X = 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 PyTypeObject __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.__pyx_scope_struct_6_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr, /*tp_traverse*/
  __pyx_tp_clear_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*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_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_array_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_array_obj *)o);
  p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_array(PyObject *o) {
  struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_array___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->mode);
  Py_CLEAR(p->_format);
  (*Py_TYPE(o)->tp_free)(o);
}
static PyObject *__pyx_sq_item_array(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_array(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_array___setitem__(o, i, v);
  }
  else {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
  PyObject *v = PyObject_GenericGetAttr(o, n);
  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
    PyErr_Clear();
    v = __pyx_array___getattr__(o, n);
  }
  return v;
}

static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
  return get_memview(o);
}

static PyMethodDef __pyx_methods_array[] = {
  {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_array[] = {
  {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_array = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_array, /*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_array = {
  0, /*mp_length*/
  __pyx_array___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_array = {
  #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
  __pyx_array_getbuffer, /*bf_getbuffer*/
  0, /*bf_releasebuffer*/
};

static PyTypeObject __pyx_type___pyx_array = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.array", /*tp_name*/
  sizeof(struct __pyx_array_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_array, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  __pyx_tp_getattro_array, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|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_array, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_array, /*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_array, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_MemviewEnum_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_MemviewEnum_obj *)o);
  p->name = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_Enum(PyObject *o) {
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->name);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  if (p->name) {
    e = (*v)(p->name, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_Enum(PyObject *o) {
  PyObject* tmp;
  struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
  tmp = ((PyObject*)p->name);
  p->name = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_Enum[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type___pyx_MemviewEnum = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.Enum", /*tp_name*/
  sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_Enum, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_MemviewEnum___repr__, /*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_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_Enum, /*tp_traverse*/
  __pyx_tp_clear_Enum, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_Enum, /*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_MemviewEnum___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_Enum, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;

static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_memoryview_obj *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_memoryview_obj *)o);
  p->__pyx_vtab = __pyx_vtabptr_memoryview;
  p->obj = Py_None; Py_INCREF(Py_None);
  p->_size = Py_None; Py_INCREF(Py_None);
  p->_array_interface = Py_None; Py_INCREF(Py_None);
  p->view.obj = NULL;
  if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_memoryview(PyObject *o) {
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_memoryview___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->obj);
  Py_CLEAR(p->_size);
  Py_CLEAR(p->_array_interface);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  if (p->obj) {
    e = (*v)(p->obj, a); if (e) return e;
  }
  if (p->_size) {
    e = (*v)(p->_size, a); if (e) return e;
  }
  if (p->_array_interface) {
    e = (*v)(p->_array_interface, a); if (e) return e;
  }
  if (p->view.obj) {
    e = (*v)(p->view.obj, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_memoryview(PyObject *o) {
  PyObject* tmp;
  struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
  tmp = ((PyObject*)p->obj);
  p->obj = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_size);
  p->_size = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_array_interface);
  p->_array_interface = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  Py_CLEAR(p->view.obj);
  return 0;
}
static PyObject *__pyx_sq_item_memoryview(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_memoryview(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_memoryview___setitem__(o, i, v);
  }
  else {
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
    return -1;
  }
}

static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_transpose(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview__get__base(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_shape(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_strides(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_suboffsets(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_ndim(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_itemsize(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_nbytes(o);
}

static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryview_get_size(o);
}

static PyMethodDef __pyx_methods_memoryview[] = {
  {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
  {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
  {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
  {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_memoryview[] = {
  {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, 0, 0},
  {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, 0, 0},
  {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, 0, 0},
  {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, 0, 0},
  {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, 0, 0},
  {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, 0, 0},
  {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, 0, 0},
  {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, 0, 0},
  {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
  __pyx_memoryview___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_memoryview, /*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_memoryview = {
  __pyx_memoryview___len__, /*mp_length*/
  __pyx_memoryview___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
  #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
  __pyx_memoryview_getbuffer, /*bf_getbuffer*/
  0, /*bf_releasebuffer*/
};

static PyTypeObject __pyx_type___pyx_memoryview = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools.memoryview", /*tp_name*/
  sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  __pyx_memoryview___repr__, /*tp_repr*/
  0, /*tp_as_number*/
  &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_memoryview___str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_memoryview, /*tp_traverse*/
  __pyx_tp_clear_memoryview, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_memoryview, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_memoryview, /*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_memoryview, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;

static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_memoryviewslice_obj *p;
  PyObject *o = __pyx_tp_new_memoryview(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_memoryviewslice_obj *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
  p->from_object = Py_None; Py_INCREF(Py_None);
  p->from_slice.memview = NULL;
  return o;
}

static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_memoryviewslice___dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->from_object);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_memoryview(o);
}

static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
  if (p->from_object) {
    e = (*v)(p->from_object, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
  PyObject* tmp;
  struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
  __pyx_tp_clear_memoryview(o);
  tmp = ((PyObject*)p->from_object);
  p->from_object = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
  return 0;
}

static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_memoryviewslice__get__base(o);
}

static PyMethodDef __pyx_methods__memoryviewslice[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
  {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type___pyx_memoryviewslice = {
  PyVarObject_HEAD_INIT(0, 0)
  "plastid.genomics.roitools._memoryviewslice", /*tp_name*/
  sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_memoryview___repr__, /*tp_repr*/
  #else
  0, /*tp_repr*/
  #endif
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_memoryview___str__, /*tp_str*/
  #else
  0, /*tp_str*/
  #endif
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Internal class for passing memoryview slices to Python", /*tp_doc*/
  __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
  __pyx_tp_clear__memoryviewslice, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods__memoryviewslice, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets__memoryviewslice, /*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__memoryviewslice, /*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*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {"positions_to_segments", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_7positions_to_segments, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_6positions_to_segments},
  {"positionlist_to_segments", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_9positionlist_to_segments, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7plastid_8genomics_8roitools_8positionlist_to_segments},
  {"add_three_for_stop_codon", (PyCFunction)__pyx_pw_7plastid_8genomics_8roitools_11add_three_for_stop_codon, METH_O, __pyx_doc_7plastid_8genomics_8roitools_10add_three_for_stop_codon},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    "roitools",
    __pyx_k_This_module_defines_object_types, /* 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_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
  {&__pyx_kp_s_0, __pyx_k_0, sizeof(__pyx_k_0), 0, 0, 1, 0},
  {&__pyx_kp_s_000000, __pyx_k_000000, sizeof(__pyx_k_000000), 0, 0, 1, 0},
  {&__pyx_kp_s_0_0_0, __pyx_k_0_0_0, sizeof(__pyx_k_0_0_0), 0, 0, 1, 0},
  {&__pyx_kp_s_0_9_0_9, __pyx_k_0_9_0_9, sizeof(__pyx_k_0_9_0_9), 0, 0, 1, 0},
  {&__pyx_kp_s_0_9_0_9_2, __pyx_k_0_9_0_9_2, sizeof(__pyx_k_0_9_0_9_2), 0, 0, 1, 0},
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_3UTR, __pyx_k_3UTR, sizeof(__pyx_k_3UTR), 0, 0, 1, 0},
  {&__pyx_kp_s_5UTR, __pyx_k_5UTR, sizeof(__pyx_k_5UTR), 0, 0, 1, 0},
  {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
  {&__pyx_kp_s_Attempted_export_of_multi_interv, __pyx_k_Attempted_export_of_multi_interv, sizeof(__pyx_k_Attempted_export_of_multi_interv), 0, 0, 1, 0},
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_kp_s_BED_format_requires_at_least_3_c, __pyx_k_BED_format_requires_at_least_3_c, sizeof(__pyx_k_BED_format_requires_at_least_3_c), 0, 0, 1, 0},
  {&__pyx_n_s_Bio_Alphabet, __pyx_k_Bio_Alphabet, sizeof(__pyx_k_Bio_Alphabet), 0, 0, 1, 1},
  {&__pyx_n_s_Bio_Seq, __pyx_k_Bio_Seq, sizeof(__pyx_k_Bio_Seq), 0, 0, 1, 1},
  {&__pyx_n_s_Bio_SeqRecord, __pyx_k_Bio_SeqRecord, sizeof(__pyx_k_Bio_SeqRecord), 0, 0, 1, 1},
  {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0},
  {&__pyx_n_s_CDS, __pyx_k_CDS, sizeof(__pyx_k_CDS), 0, 0, 1, 1},
  {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_fetch_coordinate_s_from_S, __pyx_k_Cannot_fetch_coordinate_s_from_S, sizeof(__pyx_k_Cannot_fetch_coordinate_s_from_S), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_make_SegmentChain_from_BE, __pyx_k_Cannot_make_SegmentChain_from_BE, sizeof(__pyx_k_Cannot_make_SegmentChain_from_BE), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_make_SegmentChain_from_BE_2, __pyx_k_Cannot_make_SegmentChain_from_BE_2, sizeof(__pyx_k_Cannot_make_SegmentChain_from_BE_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Cannot_make_SegmentChain_from_BE_3, __pyx_k_Cannot_make_SegmentChain_from_BE_3, sizeof(__pyx_k_Cannot_make_SegmentChain_from_BE_3), 0, 0, 1, 0},
  {&__pyx_kp_s_Comparison_operation_not_defined, __pyx_k_Comparison_operation_not_defined, sizeof(__pyx_k_Comparison_operation_not_defined), 0, 0, 1, 0},
  {&__pyx_n_s_DOUBLE, __pyx_k_DOUBLE, sizeof(__pyx_k_DOUBLE), 0, 0, 1, 1},
  {&__pyx_n_s_DataWarning, __pyx_k_DataWarning, sizeof(__pyx_k_DataWarning), 0, 0, 1, 1},
  {&__pyx_n_s_DeprecationWarning, __pyx_k_DeprecationWarning, sizeof(__pyx_k_DeprecationWarning), 0, 0, 1, 1},
  {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
  {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0},
  {&__pyx_n_s_FLOAT, __pyx_k_FLOAT, sizeof(__pyx_k_FLOAT), 0, 0, 1, 1},
  {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
  {&__pyx_n_s_GenomicSegment, __pyx_k_GenomicSegment, sizeof(__pyx_k_GenomicSegment), 0, 0, 1, 1},
  {&__pyx_kp_s_GenomicSegment___eq, __pyx_k_GenomicSegment___eq, sizeof(__pyx_k_GenomicSegment___eq), 0, 0, 1, 0},
  {&__pyx_kp_s_GenomicSegment_contains, __pyx_k_GenomicSegment_contains, sizeof(__pyx_k_GenomicSegment_contains), 0, 0, 1, 0},
  {&__pyx_kp_s_GenomicSegment_eq_neq, __pyx_k_GenomicSegment_eq_neq, sizeof(__pyx_k_GenomicSegment_eq_neq), 0, 0, 1, 0},
  {&__pyx_kp_s_GenomicSegment_overlaps, __pyx_k_GenomicSegment_overlaps, sizeof(__pyx_k_GenomicSegment_overlaps), 0, 0, 1, 0},
  {&__pyx_kp_s_GenomicSegment_s_s_s_s, __pyx_k_GenomicSegment_s_s_s_s, sizeof(__pyx_k_GenomicSegment_s_s_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_GenomicSegment_start_coordinate, __pyx_k_GenomicSegment_start_coordinate, sizeof(__pyx_k_GenomicSegment_start_coordinate), 0, 0, 1, 0},
  {&__pyx_n_s_ID, __pyx_k_ID, sizeof(__pyx_k_ID), 0, 0, 1, 1},
  {&__pyx_n_s_INT, __pyx_k_INT, sizeof(__pyx_k_INT), 0, 0, 1, 1},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_LONG, __pyx_k_LONG, sizeof(__pyx_k_LONG), 0, 0, 1, 1},
  {&__pyx_kp_s_List_of_extra_columns_contains_m, __pyx_k_List_of_extra_columns_contains_m, sizeof(__pyx_k_List_of_extra_columns_contains_m), 0, 0, 1, 0},
  {&__pyx_n_s_MaskedArray, __pyx_k_MaskedArray, sizeof(__pyx_k_MaskedArray), 0, 0, 1, 1},
  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0},
  {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
  {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1},
  {&__pyx_n_s_Name, __pyx_k_Name, sizeof(__pyx_k_Name), 0, 0, 1, 1},
  {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
  {&__pyx_n_s_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 0, 1, 1},
  {&__pyx_kp_s_None_None, __pyx_k_None_None, sizeof(__pyx_k_None_None), 0, 0, 1, 0},
  {&__pyx_n_s_NullChromosome, __pyx_k_NullChromosome, sizeof(__pyx_k_NullChromosome), 0, 0, 1, 1},
  {&__pyx_n_s_NullSegment, __pyx_k_NullSegment, sizeof(__pyx_k_NullSegment), 0, 0, 1, 1},
  {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
  {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0},
  {&__pyx_n_s_Parent, __pyx_k_Parent, sizeof(__pyx_k_Parent), 0, 0, 1, 1},
  {&__pyx_kp_s_Position_s_is_outside_bounds_0_s, __pyx_k_Position_s_is_outside_bounds_0_s, sizeof(__pyx_k_Position_s_is_outside_bounds_0_s), 0, 0, 1, 0},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_s_SegmentChain_add_segments_incomi, __pyx_k_SegmentChain_add_segments_incomi, sizeof(__pyx_k_SegmentChain_add_segments_incomi), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_antisense_overlaps, __pyx_k_SegmentChain_antisense_overlaps, sizeof(__pyx_k_SegmentChain_antisense_overlaps), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_antisense_overlaps_2, __pyx_k_SegmentChain_antisense_overlaps_2, sizeof(__pyx_k_SegmentChain_antisense_overlaps_2), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_covers_is_only_defi, __pyx_k_SegmentChain_covers_is_only_defi, sizeof(__pyx_k_SegmentChain_covers_is_only_defi), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_eq_ineq_et_c_is_onl, __pyx_k_SegmentChain_eq_ineq_et_c_is_onl, sizeof(__pyx_k_SegmentChain_eq_ineq_et_c_is_onl), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_get_segmentchain_co, __pyx_k_SegmentChain_get_segmentchain_co, sizeof(__pyx_k_SegmentChain_get_segmentchain_co), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_get_segmentchain_co_2, __pyx_k_SegmentChain_get_segmentchain_co_2, sizeof(__pyx_k_SegmentChain_get_segmentchain_co_2), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_overlaps_is_defined, __pyx_k_SegmentChain_overlaps_is_defined, sizeof(__pyx_k_SegmentChain_overlaps_is_defined), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_s_s, __pyx_k_SegmentChain_s_s, sizeof(__pyx_k_SegmentChain_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_shares_segments_wit, __pyx_k_SegmentChain_shares_segments_wit, sizeof(__pyx_k_SegmentChain_shares_segments_wit), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_unstranded_overlaps, __pyx_k_SegmentChain_unstranded_overlaps, sizeof(__pyx_k_SegmentChain_unstranded_overlaps), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChain_unstranded_overlaps_2, __pyx_k_SegmentChain_unstranded_overlaps_2, sizeof(__pyx_k_SegmentChain_unstranded_overlaps_2), 0, 0, 1, 0},
  {&__pyx_kp_s_SegmentChains_only_support_PSL_o, __pyx_k_SegmentChains_only_support_PSL_o, sizeof(__pyx_k_SegmentChains_only_support_PSL_o), 0, 0, 1, 0},
  {&__pyx_kp_s_Segmentchain_adding_segments_to, __pyx_k_Segmentchain_adding_segments_to, sizeof(__pyx_k_Segmentchain_adding_segments_to), 0, 0, 1, 0},
  {&__pyx_n_s_Seq, __pyx_k_Seq, sizeof(__pyx_k_Seq), 0, 0, 1, 1},
  {&__pyx_n_s_SeqRecord, __pyx_k_SeqRecord, sizeof(__pyx_k_SeqRecord), 0, 0, 1, 1},
  {&__pyx_kp_s_Strand_for_SegmentChain_s_is_und, __pyx_k_Strand_for_SegmentChain_s_is_und, sizeof(__pyx_k_Strand_for_SegmentChain_s_is_und), 0, 0, 1, 0},
  {&__pyx_kp_s_Strand_must_be_or_x00_undefined, __pyx_k_Strand_must_be_or_x00_undefined, sizeof(__pyx_k_Strand_must_be_or_x00_undefined), 0, 0, 1, 0},
  {&__pyx_kp_s_The_in_containment_operator_is_o, __pyx_k_The_in_containment_operator_is_o, sizeof(__pyx_k_The_in_containment_operator_is_o), 0, 0, 1, 0},
  {&__pyx_kp_s_This_operation_is_not_defined_fo, __pyx_k_This_operation_is_not_defined_fo, sizeof(__pyx_k_This_operation_is_not_defined_fo), 0, 0, 1, 0},
  {&__pyx_kp_s_This_operation_is_not_defined_fo_2, __pyx_k_This_operation_is_not_defined_fo_2, sizeof(__pyx_k_This_operation_is_not_defined_fo_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Transcript_s_ID_s_cds_genome_sta, __pyx_k_Transcript_s_ID_s_cds_genome_sta, sizeof(__pyx_k_Transcript_s_ID_s_cds_genome_sta), 0, 0, 1, 0},
  {&__pyx_kp_s_Transcript_s_cds_end_s_must_be_c, __pyx_k_Transcript_s_cds_end_s_must_be_c, sizeof(__pyx_k_Transcript_s_cds_end_s_must_be_c), 0, 0, 1, 0},
  {&__pyx_kp_s_Transcript_s_cds_end_s_must_be_s, __pyx_k_Transcript_s_cds_end_s_must_be_s, sizeof(__pyx_k_Transcript_s_cds_end_s_must_be_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Transcript_s_cds_genome_end_s_mu, __pyx_k_Transcript_s_cds_genome_end_s_mu, sizeof(__pyx_k_Transcript_s_cds_genome_end_s_mu), 0, 0, 1, 0},
  {&__pyx_kp_s_Transcript_s_cds_genome_start_s, __pyx_k_Transcript_s_cds_genome_start_s, sizeof(__pyx_k_Transcript_s_cds_genome_start_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Transcript_s_cds_start_s_must_be, __pyx_k_Transcript_s_cds_start_s_must_be, sizeof(__pyx_k_Transcript_s_cds_start_s_must_be), 0, 0, 1, 0},
  {&__pyx_kp_s_Transcript_s_cds_start_s_must_be_2, __pyx_k_Transcript_s_cds_start_s_must_be_2, sizeof(__pyx_k_Transcript_s_cds_start_s_must_be_2), 0, 0, 1, 0},
  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0},
  {&__pyx_n_s_UserWarning, __pyx_k_UserWarning, sizeof(__pyx_k_UserWarning), 0, 0, 1, 1},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1},
  {&__pyx_kp_s__12, __pyx_k__12, sizeof(__pyx_k__12), 0, 0, 1, 0},
  {&__pyx_kp_s__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 0, 1, 0},
  {&__pyx_kp_s__16, __pyx_k__16, sizeof(__pyx_k__16), 0, 0, 1, 0},
  {&__pyx_kp_s__17, __pyx_k__17, sizeof(__pyx_k__17), 0, 0, 1, 0},
  {&__pyx_kp_s__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 0, 1, 0},
  {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
  {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
  {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
  {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0},
  {&__pyx_kp_s__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 0, 1, 0},
  {&__pyx_kp_s__74, __pyx_k__74, sizeof(__pyx_k__74), 0, 0, 1, 0},
  {&__pyx_n_s_alignment, __pyx_k_alignment, sizeof(__pyx_k_alignment), 0, 0, 1, 1},
  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
  {&__pyx_n_s_as_bed, __pyx_k_as_bed, sizeof(__pyx_k_as_bed), 0, 0, 1, 1},
  {&__pyx_n_s_as_bed_locals_genexpr, __pyx_k_as_bed_locals_genexpr, sizeof(__pyx_k_as_bed_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_as_gff3, __pyx_k_as_gff3, sizeof(__pyx_k_as_gff3), 0, 0, 1, 1},
  {&__pyx_n_s_as_gtf, __pyx_k_as_gtf, sizeof(__pyx_k_as_gtf), 0, 0, 1, 1},
  {&__pyx_n_s_as_igv_str, __pyx_k_as_igv_str, sizeof(__pyx_k_as_igv_str), 0, 0, 1, 1},
  {&__pyx_n_s_as_int, __pyx_k_as_int, sizeof(__pyx_k_as_int), 0, 0, 1, 1},
  {&__pyx_n_s_as_psl_locals_genexpr, __pyx_k_as_psl_locals_genexpr, sizeof(__pyx_k_as_psl_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_attr, __pyx_k_attr, sizeof(__pyx_k_attr), 0, 0, 1, 1},
  {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
  {&__pyx_n_s_bed_columns, __pyx_k_bed_columns, sizeof(__pyx_k_bed_columns), 0, 0, 1, 1},
  {&__pyx_n_s_bedx_column_order, __pyx_k_bedx_column_order, sizeof(__pyx_k_bedx_column_order), 0, 0, 1, 1},
  {&__pyx_n_s_block_size, __pyx_k_block_size, sizeof(__pyx_k_block_size), 0, 0, 1, 1},
  {&__pyx_n_s_block_sizes, __pyx_k_block_sizes, sizeof(__pyx_k_block_sizes), 0, 0, 1, 1},
  {&__pyx_n_s_block_starts, __pyx_k_block_starts, sizeof(__pyx_k_block_starts), 0, 0, 1, 1},
  {&__pyx_n_s_blocks, __pyx_k_blocks, sizeof(__pyx_k_blocks), 0, 0, 1, 1},
  {&__pyx_n_s_blocksizes, __pyx_k_blocksizes, sizeof(__pyx_k_blocksizes), 0, 0, 1, 1},
  {&__pyx_n_s_blockstarts, __pyx_k_blockstarts, sizeof(__pyx_k_blockstarts), 0, 0, 1, 1},
  {&__pyx_kp_s_bounds_s_s_s_s, __pyx_k_bounds_s_s_s_s, sizeof(__pyx_k_bounds_s_s_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
  {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
  {&__pyx_n_s_c_strand, __pyx_k_c_strand, sizeof(__pyx_k_c_strand), 0, 0, 1, 1},
  {&__pyx_n_s_cds_genome_end, __pyx_k_cds_genome_end, sizeof(__pyx_k_cds_genome_end), 0, 0, 1, 1},
  {&__pyx_n_s_cds_genome_start, __pyx_k_cds_genome_start, sizeof(__pyx_k_cds_genome_start), 0, 0, 1, 1},
  {&__pyx_n_s_chrom, __pyx_k_chrom, sizeof(__pyx_k_chrom), 0, 0, 1, 1},
  {&__pyx_n_s_chrom_end, __pyx_k_chrom_end, sizeof(__pyx_k_chrom_end), 0, 0, 1, 1},
  {&__pyx_n_s_chrom_start, __pyx_k_chrom_start, sizeof(__pyx_k_chrom_start), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_cmp_helper, __pyx_k_cmp_helper, sizeof(__pyx_k_cmp_helper), 0, 0, 1, 1},
  {&__pyx_n_s_cmptype, __pyx_k_cmptype, sizeof(__pyx_k_cmptype), 0, 0, 1, 1},
  {&__pyx_n_s_color, __pyx_k_color, sizeof(__pyx_k_color), 0, 0, 1, 1},
  {&__pyx_n_s_column_formatters, __pyx_k_column_formatters, sizeof(__pyx_k_column_formatters), 0, 0, 1, 1},
  {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
  {&__pyx_n_s_contains, __pyx_k_contains, sizeof(__pyx_k_contains), 0, 0, 1, 1},
  {&__pyx_n_s_contains_2, __pyx_k_contains_2, sizeof(__pyx_k_contains_2), 0, 0, 1, 1},
  {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
  {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
  {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
  {&__pyx_n_s_copy_2, __pyx_k_copy_2, sizeof(__pyx_k_copy_2), 0, 0, 1, 1},
  {&__pyx_kp_s_custom_s, __pyx_k_custom_s, sizeof(__pyx_k_custom_s), 0, 0, 1, 0},
  {&__pyx_n_s_deepcopy, __pyx_k_deepcopy, sizeof(__pyx_k_deepcopy), 0, 0, 1, 1},
  {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1},
  {&__pyx_n_s_default_id, __pyx_k_default_id, sizeof(__pyx_k_default_id), 0, 0, 1, 1},
  {&__pyx_n_s_deprecated, __pyx_k_deprecated, sizeof(__pyx_k_deprecated), 0, 0, 1, 1},
  {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1},
  {&__pyx_n_s_dtmp, __pyx_k_dtmp, sizeof(__pyx_k_dtmp), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_kp_s_end_coordinate_supplied_is_None, __pyx_k_end_coordinate_supplied_is_None, sizeof(__pyx_k_end_coordinate_supplied_is_None), 0, 0, 1, 0},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_n_s_escape, __pyx_k_escape, sizeof(__pyx_k_escape), 0, 0, 1, 1},
  {&__pyx_n_s_excludes, __pyx_k_excludes, sizeof(__pyx_k_excludes), 0, 0, 1, 1},
  {&__pyx_n_s_exon, __pyx_k_exon, sizeof(__pyx_k_exon), 0, 0, 1, 1},
  {&__pyx_n_s_extra_columns, __pyx_k_extra_columns, sizeof(__pyx_k_extra_columns), 0, 0, 1, 1},
  {&__pyx_n_s_feature_type, __pyx_k_feature_type, sizeof(__pyx_k_feature_type), 0, 0, 1, 1},
  {&__pyx_n_s_five_prime_UTR, __pyx_k_five_prime_UTR, sizeof(__pyx_k_five_prime_UTR), 0, 0, 1, 1},
  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  {&__pyx_n_s_float, __pyx_k_float, sizeof(__pyx_k_float), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_format_segmentchain, __pyx_k_format_segmentchain, sizeof(__pyx_k_format_segmentchain), 0, 0, 1, 1},
  {&__pyx_n_s_format_transcript, __pyx_k_format_transcript, sizeof(__pyx_k_format_transcript), 0, 0, 1, 1},
  {&__pyx_n_s_formatter, __pyx_k_formatter, sizeof(__pyx_k_formatter), 0, 0, 1, 1},
  {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
  {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
  {&__pyx_n_s_frag_end, __pyx_k_frag_end, sizeof(__pyx_k_frag_end), 0, 0, 1, 1},
  {&__pyx_n_s_frag_offsets, __pyx_k_frag_offsets, sizeof(__pyx_k_frag_offsets), 0, 0, 1, 1},
  {&__pyx_n_s_frag_sizes, __pyx_k_frag_sizes, sizeof(__pyx_k_frag_sizes), 0, 0, 1, 1},
  {&__pyx_n_s_frag_start, __pyx_k_frag_start, sizeof(__pyx_k_frag_start), 0, 0, 1, 1},
  {&__pyx_n_s_frags, __pyx_k_frags, sizeof(__pyx_k_frags), 0, 0, 1, 1},
  {&__pyx_n_s_frame, __pyx_k_frame, sizeof(__pyx_k_frame), 0, 0, 1, 1},
  {&__pyx_n_s_from_bed, __pyx_k_from_bed, sizeof(__pyx_k_from_bed), 0, 0, 1, 1},
  {&__pyx_n_s_from_igv_str, __pyx_k_from_igv_str, sizeof(__pyx_k_from_igv_str), 0, 0, 1, 1},
  {&__pyx_n_s_from_psl, __pyx_k_from_psl, sizeof(__pyx_k_from_psl), 0, 0, 1, 1},
  {&__pyx_n_s_from_str, __pyx_k_from_str, sizeof(__pyx_k_from_str), 0, 0, 1, 1},
  {&__pyx_n_s_frombuffer, __pyx_k_frombuffer, sizeof(__pyx_k_frombuffer), 0, 0, 1, 1},
  {&__pyx_n_s_func, __pyx_k_func, sizeof(__pyx_k_func), 0, 0, 1, 1},
  {&__pyx_n_s_ga, __pyx_k_ga, sizeof(__pyx_k_ga), 0, 0, 1, 1},
  {&__pyx_kp_s_gene__s, __pyx_k_gene__s, sizeof(__pyx_k_gene__s), 0, 0, 1, 0},
  {&__pyx_n_s_gene_id, __pyx_k_gene_id, sizeof(__pyx_k_gene_id), 0, 0, 1, 1},
  {&__pyx_n_s_generic_dna, __pyx_k_generic_dna, sizeof(__pyx_k_generic_dna), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_genome, __pyx_k_genome, sizeof(__pyx_k_genome), 0, 0, 1, 1},
  {&__pyx_n_s_genomic_x, __pyx_k_genomic_x, sizeof(__pyx_k_genomic_x), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_8_gff_columns, __pyx_k_get_8_gff_columns, sizeof(__pyx_k_get_8_gff_columns), 0, 0, 1, 1},
  {&__pyx_n_s_get_antisense, __pyx_k_get_antisense, sizeof(__pyx_k_get_antisense), 0, 0, 1, 1},
  {&__pyx_n_s_get_attr, __pyx_k_get_attr, sizeof(__pyx_k_get_attr), 0, 0, 1, 1},
  {&__pyx_n_s_get_cds, __pyx_k_get_cds, sizeof(__pyx_k_get_cds), 0, 0, 1, 1},
  {&__pyx_n_s_get_counts, __pyx_k_get_counts, sizeof(__pyx_k_get_counts), 0, 0, 1, 1},
  {&__pyx_n_s_get_gene, __pyx_k_get_gene, sizeof(__pyx_k_get_gene), 0, 0, 1, 1},
  {&__pyx_n_s_get_junctions, __pyx_k_get_junctions, sizeof(__pyx_k_get_junctions), 0, 0, 1, 1},
  {&__pyx_n_s_get_length, __pyx_k_get_length, sizeof(__pyx_k_get_length), 0, 0, 1, 1},
  {&__pyx_n_s_get_masked_position_set, __pyx_k_get_masked_position_set, sizeof(__pyx_k_get_masked_position_set), 0, 0, 1, 1},
  {&__pyx_n_s_get_name, __pyx_k_get_name, sizeof(__pyx_k_get_name), 0, 0, 1, 1},
  {&__pyx_n_s_get_position_list, __pyx_k_get_position_list, sizeof(__pyx_k_get_position_list), 0, 0, 1, 1},
  {&__pyx_n_s_get_rgb255, __pyx_k_get_rgb255, sizeof(__pyx_k_get_rgb255), 0, 0, 1, 1},
  {&__pyx_n_s_get_segmentchain_coordinate, __pyx_k_get_segmentchain_coordinate, sizeof(__pyx_k_get_segmentchain_coordinate), 0, 0, 1, 1},
  {&__pyx_kp_s_get_segmentchain_coordinate_quer, __pyx_k_get_segmentchain_coordinate_quer, sizeof(__pyx_k_get_segmentchain_coordinate_quer), 0, 0, 1, 0},
  {&__pyx_kp_s_get_segmentchain_coordinate_quer_2, __pyx_k_get_segmentchain_coordinate_quer_2, sizeof(__pyx_k_get_segmentchain_coordinate_quer_2), 0, 0, 1, 0},
  {&__pyx_n_s_get_sequence, __pyx_k_get_sequence, sizeof(__pyx_k_get_sequence), 0, 0, 1, 1},
  {&__pyx_n_s_get_str_from_rgb, __pyx_k_get_str_from_rgb, sizeof(__pyx_k_get_str_from_rgb), 0, 0, 1, 1},
  {&__pyx_n_s_get_str_from_rgb255, __pyx_k_get_str_from_rgb255, sizeof(__pyx_k_get_str_from_rgb255), 0, 0, 1, 1},
  {&__pyx_n_s_get_subchain, __pyx_k_get_subchain, sizeof(__pyx_k_get_subchain), 0, 0, 1, 1},
  {&__pyx_n_s_get_utr3, __pyx_k_get_utr3, sizeof(__pyx_k_get_utr3), 0, 0, 1, 1},
  {&__pyx_n_s_get_utr5, __pyx_k_get_utr5, sizeof(__pyx_k_get_utr5), 0, 0, 1, 1},
  {&__pyx_n_s_getitem, __pyx_k_getitem, sizeof(__pyx_k_getitem), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0},
  {&__pyx_n_s_groups, __pyx_k_groups, sizeof(__pyx_k_groups), 0, 0, 1, 1},
  {&__pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_k_homeroot_joshua_projects_plasti, sizeof(__pyx_k_homeroot_joshua_projects_plasti), 0, 0, 1, 0},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_igvpat, __pyx_k_igvpat, sizeof(__pyx_k_igvpat), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_inp, __pyx_k_inp, sizeof(__pyx_k_inp), 0, 0, 1, 1},
  {&__pyx_n_s_int, __pyx_k_int, sizeof(__pyx_k_int), 0, 0, 1, 1},
  {&__pyx_n_s_intc, __pyx_k_intc, sizeof(__pyx_k_intc), 0, 0, 1, 1},
  {&__pyx_n_s_isnan, __pyx_k_isnan, sizeof(__pyx_k_isnan), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
  {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0},
  {&__pyx_n_s_iv, __pyx_k_iv, sizeof(__pyx_k_iv), 0, 0, 1, 1},
  {&__pyx_n_s_iv_ltmp, __pyx_k_iv_ltmp, sizeof(__pyx_k_iv_ltmp), 0, 0, 1, 1},
  {&__pyx_n_s_ivcpat, __pyx_k_ivcpat, sizeof(__pyx_k_ivcpat), 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_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1},
  {&__pyx_n_s_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 0, 1, 1},
  {&__pyx_n_s_loc_str, __pyx_k_loc_str, sizeof(__pyx_k_loc_str), 0, 0, 1, 1},
  {&__pyx_n_s_long, __pyx_k_long, sizeof(__pyx_k_long), 0, 0, 1, 1},
  {&__pyx_n_s_ltmp, __pyx_k_ltmp, sizeof(__pyx_k_ltmp), 0, 0, 1, 1},
  {&__pyx_n_s_mRNA, __pyx_k_mRNA, sizeof(__pyx_k_mRNA), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_make_GFF3_tokens, __pyx_k_make_GFF3_tokens, sizeof(__pyx_k_make_GFF3_tokens), 0, 0, 1, 1},
  {&__pyx_n_s_make_GTF2_tokens, __pyx_k_make_GTF2_tokens, sizeof(__pyx_k_make_GTF2_tokens), 0, 0, 1, 1},
  {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
  {&__pyx_n_s_match_length, __pyx_k_match_length, sizeof(__pyx_k_match_length), 0, 0, 1, 1},
  {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
  {&__pyx_n_s_middle, __pyx_k_middle, sizeof(__pyx_k_middle), 0, 0, 1, 1},
  {&__pyx_n_s_mismatches, __pyx_k_mismatches, sizeof(__pyx_k_mismatches), 0, 0, 1, 1},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 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_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_kp_s_name_s, __pyx_k_name_s, sizeof(__pyx_k_name_s), 0, 0, 1, 0},
  {&__pyx_n_s_nan, __pyx_k_nan, sizeof(__pyx_k_nan), 0, 0, 1, 1},
  {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
  {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
  {&__pyx_n_s_next, __pyx_k_next, sizeof(__pyx_k_next), 0, 0, 1, 1},
  {&__pyx_n_s_none, __pyx_k_none, sizeof(__pyx_k_none), 0, 0, 1, 1},
  {&__pyx_n_s_num_bed_columns, __pyx_k_num_bed_columns, sizeof(__pyx_k_num_bed_columns), 0, 0, 1, 1},
  {&__pyx_n_s_num_extra_columns, __pyx_k_num_extra_columns, sizeof(__pyx_k_num_extra_columns), 0, 0, 1, 1},
  {&__pyx_n_s_num_frags, __pyx_k_num_frags, sizeof(__pyx_k_num_frags), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_n_s_numpy_ma, __pyx_k_numpy_ma, sizeof(__pyx_k_numpy_ma), 0, 0, 1, 1},
  {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
  {&__pyx_n_s_other, __pyx_k_other, sizeof(__pyx_k_other), 0, 0, 1, 1},
  {&__pyx_n_s_overlaps, __pyx_k_overlaps, sizeof(__pyx_k_overlaps), 0, 0, 1, 1},
  {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
  {&__pyx_n_s_phase, __pyx_k_phase, sizeof(__pyx_k_phase), 0, 0, 1, 1},
  {&__pyx_n_s_piece, __pyx_k_piece, sizeof(__pyx_k_piece), 0, 0, 1, 1},
  {&__pyx_n_s_plastid_genomics_roitools, __pyx_k_plastid_genomics_roitools, sizeof(__pyx_k_plastid_genomics_roitools), 0, 0, 1, 1},
  {&__pyx_n_s_plastid_plotting_colors, __pyx_k_plastid_plotting_colors, sizeof(__pyx_k_plastid_plotting_colors), 0, 0, 1, 1},
  {&__pyx_n_s_plastid_readers_gff_tokens, __pyx_k_plastid_readers_gff_tokens, sizeof(__pyx_k_plastid_readers_gff_tokens), 0, 0, 1, 1},
  {&__pyx_n_s_plastid_util_services_decorators, __pyx_k_plastid_util_services_decorators, sizeof(__pyx_k_plastid_util_services_decorators), 0, 0, 1, 1},
  {&__pyx_n_s_plastid_util_services_exceptions, __pyx_k_plastid_util_services_exceptions, sizeof(__pyx_k_plastid_util_services_exceptions), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_positions, __pyx_k_positions, sizeof(__pyx_k_positions), 0, 0, 1, 1},
  {&__pyx_n_s_psl_line, __pyx_k_psl_line, sizeof(__pyx_k_psl_line), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_q_starts, __pyx_k_q_starts, sizeof(__pyx_k_q_starts), 0, 0, 1, 1},
  {&__pyx_n_s_query_end, __pyx_k_query_end, sizeof(__pyx_k_query_end), 0, 0, 1, 1},
  {&__pyx_n_s_query_gap_bases, __pyx_k_query_gap_bases, sizeof(__pyx_k_query_gap_bases), 0, 0, 1, 1},
  {&__pyx_n_s_query_gap_count, __pyx_k_query_gap_count, sizeof(__pyx_k_query_gap_count), 0, 0, 1, 1},
  {&__pyx_n_s_query_length, __pyx_k_query_length, sizeof(__pyx_k_query_length), 0, 0, 1, 1},
  {&__pyx_n_s_query_name, __pyx_k_query_name, sizeof(__pyx_k_query_name), 0, 0, 1, 1},
  {&__pyx_n_s_query_start, __pyx_k_query_start, sizeof(__pyx_k_query_start), 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_rep_matches, __pyx_k_rep_matches, sizeof(__pyx_k_rep_matches), 0, 0, 1, 1},
  {&__pyx_n_s_reverse_complement, __pyx_k_reverse_complement, sizeof(__pyx_k_reverse_complement), 0, 0, 1, 1},
  {&__pyx_n_s_rna_type, __pyx_k_rna_type, sizeof(__pyx_k_rna_type), 0, 0, 1, 1},
  {&__pyx_n_s_roi_order, __pyx_k_roi_order, sizeof(__pyx_k_roi_order), 0, 0, 1, 1},
  {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1},
  {&__pyx_kp_s_s_3UTR, __pyx_k_s_3UTR, sizeof(__pyx_k_s_3UTR), 0, 0, 1, 0},
  {&__pyx_kp_s_s_5UTR, __pyx_k_s_5UTR, sizeof(__pyx_k_s_5UTR), 0, 0, 1, 0},
  {&__pyx_n_s_s_end, __pyx_k_s_end, sizeof(__pyx_k_s_end), 0, 0, 1, 1},
  {&__pyx_kp_s_s_exon_s, __pyx_k_s_exon_s, sizeof(__pyx_k_s_exon_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_get_length_is_deprecated_and, __pyx_k_s_get_length_is_deprecated_and, sizeof(__pyx_k_s_get_length_is_deprecated_and), 0, 0, 1, 0},
  {&__pyx_kp_s_s_get_masked_length_is_deprecat, __pyx_k_s_get_masked_length_is_deprecat, sizeof(__pyx_k_s_get_masked_length_is_deprecat), 0, 0, 1, 0},
  {&__pyx_kp_s_s_is_a_zero_length_SegmentChain, __pyx_k_s_is_a_zero_length_SegmentChain, sizeof(__pyx_k_s_is_a_zero_length_SegmentChain), 0, 0, 1, 0},
  {&__pyx_kp_s_s_is_a_zero_length_SegmentChain_2, __pyx_k_s_is_a_zero_length_SegmentChain_2, sizeof(__pyx_k_s_is_a_zero_length_SegmentChain_2), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_2, __pyx_k_s_s_2, sizeof(__pyx_k_s_s_2), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_3, __pyx_k_s_s_3, sizeof(__pyx_k_s_s_3), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s, __pyx_k_s_s_s, sizeof(__pyx_k_s_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s_2, __pyx_k_s_s_s_2, sizeof(__pyx_k_s_s_s_2), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s_3, __pyx_k_s_s_s_3, sizeof(__pyx_k_s_s_s_3), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s_4, __pyx_k_s_s_s_4, sizeof(__pyx_k_s_s_s_4), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s_s, __pyx_k_s_s_s_s, sizeof(__pyx_k_s_s_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s_s_s_strand_s, __pyx_k_s_s_s_s_strand_s, sizeof(__pyx_k_s_s_s_s_strand_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_segments_s, __pyx_k_s_segments_s, sizeof(__pyx_k_s_segments_s), 0, 0, 1, 0},
  {&__pyx_n_s_s_start, __pyx_k_s_start, sizeof(__pyx_k_s_start), 0, 0, 1, 1},
  {&__pyx_kp_s_s_subchain, __pyx_k_s_subchain, sizeof(__pyx_k_s_subchain), 0, 0, 1, 0},
  {&__pyx_kp_s_s_value_of_s_cannot_be_None, __pyx_k_s_value_of_s_cannot_be_None, sizeof(__pyx_k_s_value_of_s_cannot_be_None), 0, 0, 1, 0},
  {&__pyx_n_s_score, __pyx_k_score, sizeof(__pyx_k_score), 0, 0, 1, 1},
  {&__pyx_n_s_search, __pyx_k_search, sizeof(__pyx_k_search), 0, 0, 1, 1},
  {&__pyx_n_s_seg, __pyx_k_seg, sizeof(__pyx_k_seg), 0, 0, 1, 1},
  {&__pyx_n_s_segchain, __pyx_k_segchain, sizeof(__pyx_k_segchain), 0, 0, 1, 1},
  {&__pyx_n_s_segment, __pyx_k_segment, sizeof(__pyx_k_segment), 0, 0, 1, 1},
  {&__pyx_n_s_segments, __pyx_k_segments, sizeof(__pyx_k_segments), 0, 0, 1, 1},
  {&__pyx_n_s_segpat, __pyx_k_segpat, sizeof(__pyx_k_segpat), 0, 0, 1, 1},
  {&__pyx_n_s_segs, __pyx_k_segs, sizeof(__pyx_k_segs), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_seq, __pyx_k_seq, sizeof(__pyx_k_seq), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_source, __pyx_k_source, sizeof(__pyx_k_source), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_sstart, __pyx_k_sstart, sizeof(__pyx_k_sstart), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_start_codon, __pyx_k_start_codon, sizeof(__pyx_k_start_codon), 0, 0, 1, 1},
  {&__pyx_kp_s_start_coordinate_supplied_is_Non, __pyx_k_start_coordinate_supplied_is_Non, sizeof(__pyx_k_start_coordinate_supplied_is_Non), 0, 0, 1, 0},
  {&__pyx_n_s_staticmethod, __pyx_k_staticmethod, sizeof(__pyx_k_staticmethod), 0, 0, 1, 1},
  {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
  {&__pyx_n_s_stmp, __pyx_k_stmp, sizeof(__pyx_k_stmp), 0, 0, 1, 1},
  {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
  {&__pyx_n_s_stop_codon, __pyx_k_stop_codon, sizeof(__pyx_k_stop_codon), 0, 0, 1, 1},
  {&__pyx_n_s_strand, __pyx_k_strand, sizeof(__pyx_k_strand), 0, 0, 1, 1},
  {&__pyx_kp_s_strand_to_str_Strand_must_be_for, __pyx_k_strand_to_str_Strand_must_be_for, sizeof(__pyx_k_strand_to_str_Strand_must_be_for), 0, 0, 1, 0},
  {&__pyx_kp_s_strand_undefined, __pyx_k_strand_undefined, sizeof(__pyx_k_strand_undefined), 0, 0, 1, 0},
  {&__pyx_n_s_stranded, __pyx_k_stranded, sizeof(__pyx_k_stranded), 0, 0, 1, 1},
  {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
  {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0},
  {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_t_start, __pyx_k_t_start, sizeof(__pyx_k_t_start), 0, 0, 1, 1},
  {&__pyx_n_s_t_starts, __pyx_k_t_starts, sizeof(__pyx_k_t_starts), 0, 0, 1, 1},
  {&__pyx_n_s_target_end, __pyx_k_target_end, sizeof(__pyx_k_target_end), 0, 0, 1, 1},
  {&__pyx_n_s_target_gap_bases, __pyx_k_target_gap_bases, sizeof(__pyx_k_target_gap_bases), 0, 0, 1, 1},
  {&__pyx_n_s_target_gap_count, __pyx_k_target_gap_count, sizeof(__pyx_k_target_gap_count), 0, 0, 1, 1},
  {&__pyx_n_s_target_length, __pyx_k_target_length, sizeof(__pyx_k_target_length), 0, 0, 1, 1},
  {&__pyx_n_s_target_name, __pyx_k_target_name, sizeof(__pyx_k_target_name), 0, 0, 1, 1},
  {&__pyx_n_s_target_start, __pyx_k_target_start, sizeof(__pyx_k_target_start), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_thickend, __pyx_k_thickend, sizeof(__pyx_k_thickend), 0, 0, 1, 1},
  {&__pyx_n_s_thickstart, __pyx_k_thickstart, sizeof(__pyx_k_thickstart), 0, 0, 1, 1},
  {&__pyx_n_s_three_prime_UTR, __pyx_k_three_prime_UTR, sizeof(__pyx_k_three_prime_UTR), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1},
  {&__pyx_n_s_transcript, __pyx_k_transcript, sizeof(__pyx_k_transcript), 0, 0, 1, 1},
  {&__pyx_n_s_transcript_id, __pyx_k_transcript_id, sizeof(__pyx_k_transcript_id), 0, 0, 1, 1},
  {&__pyx_n_s_tup, __pyx_k_tup, sizeof(__pyx_k_tup), 0, 0, 1, 1},
  {&__pyx_n_s_tx, __pyx_k_tx, sizeof(__pyx_k_tx), 0, 0, 1, 1},
  {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1},
  {&__pyx_n_s_types, __pyx_k_types, sizeof(__pyx_k_types), 0, 0, 1, 1},
  {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0},
  {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0},
  {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
  {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
  {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1},
  {&__pyx_kp_s_wrong_and_or_multiple_chromosom, __pyx_k_wrong_and_or_multiple_chromosom, sizeof(__pyx_k_wrong_and_or_multiple_chromosom), 0, 0, 1, 0},
  {&__pyx_kp_s_wrong_and_or_multiple_strands, __pyx_k_wrong_and_or_multiple_strands, sizeof(__pyx_k_wrong_and_or_multiple_strands), 0, 0, 1, 0},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 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_staticmethod = __Pyx_GetBuiltinName(__pyx_n_s_staticmethod); if (!__pyx_builtin_staticmethod) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_DeprecationWarning = __Pyx_GetBuiltinName(__pyx_n_s_DeprecationWarning); if (!__pyx_builtin_DeprecationWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_UserWarning = __Pyx_GetBuiltinName(__pyx_n_s_UserWarning); if (!__pyx_builtin_UserWarning) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_round = __Pyx_GetBuiltinName(__pyx_n_s_round); if (!__pyx_builtin_round) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_all = __Pyx_GetBuiltinName(__pyx_n_s_all); if (!__pyx_builtin_all) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_any = __Pyx_GetBuiltinName(__pyx_n_s_any); if (!__pyx_builtin_any) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 571; __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);

  /* "plastid/genomics/roitools.pyx":399
 *         return undef_strand
 *     else:
 *         raise ValueError("Strand must be '+', '-', '.', or '\\x00' (undefined)")             # <<<<<<<<<<<<<<
 * 
 * cdef bint check_segments(SegmentChain chain, tuple segments) except False:
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Strand_must_be_or_x00_undefined); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "plastid/genomics/roitools.pyx":516
 *                     else false
 *     else:
 *         raise ValueError("This operation is not defined for SegmentChains.")             # <<<<<<<<<<<<<<
 * 
 * cdef ExBool transcript_richcmp(Transcript chain1, Transcript chain2, int cmpval) except bool_exception:
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_This_operation_is_not_defined_fo); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "plastid/genomics/roitools.pyx":578
 *                     else false
 *     else:
 *         raise ValueError("This operation is not defined for Transcripts.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_This_operation_is_not_defined_fo_2); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "plastid/genomics/roitools.pyx":781
 *             return other._cmp_helper(self,LT) or self._cmp_helper(other,EQ)
 *         else:
 *             raise AttributeError("Comparison operation not defined")             # <<<<<<<<<<<<<<
 * 
 *     def __contains__(self,other):
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Comparison_operation_not_defined); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "plastid/genomics/roitools.pyx":1207
 *             return chain_richcmp(self,SegmentChain(other),cmpval) == true
 *         else:
 *             raise TypeError("SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.")             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_SegmentChain_eq_ineq_et_c_is_onl); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);

  /* "plastid/genomics/roitools.pyx":1311
 *             return retval == true
 *         else:
 *             raise TypeError("The 'in'/containment operator is only defined for GenomicSegments and SegmentChains")             # <<<<<<<<<<<<<<
 * 
 *     cdef ExBool c_contains(self, SegmentChain other) except bool_exception:
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_The_in_containment_operator_is_o); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "plastid/genomics/roitools.pyx":2436
 *             return "\t".join(str(X) for X in ltmp) + "\n"
 *         except KeyError:
 *             raise AttributeError("SegmentChains only support PSL output if all PSL attributes are defined in self.attr: match_length, mismatches, rep_matches, N, query_gap_count, query_gap_bases, strand, query_length, query_start, query_end, target_name, target_length, target_start, target_end")             # <<<<<<<<<<<<<<
 * 
 *     def get_segmentchain_coordinate(self, str chrom, long genomic_x, str strand, bint stranded = True):
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_SegmentChains_only_support_PSL_o); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "plastid/genomics/roitools.pyx":2682
 * 
 *         if start is None:
 *             raise TypeError('start coordinate supplied is None. Expected int')             # <<<<<<<<<<<<<<
 *         elif end is None:
 *             raise TypeError('end coordinate supplied is None. Expected int')
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_start_coordinate_supplied_is_Non); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "plastid/genomics/roitools.pyx":2684
 *             raise TypeError('start coordinate supplied is None. Expected int')
 *         elif end is None:
 *             raise TypeError('end coordinate supplied is None. Expected int')             # <<<<<<<<<<<<<<
 * 
 *         if stranded == True and self.c_strand == reverse_strand:
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_end_coordinate_supplied_is_None); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "plastid/genomics/roitools.pyx":2732
 * 
 *         if self.c_strand == reverse_strand and stranded is True:
 *             count_array = count_array[::-1]             # <<<<<<<<<<<<<<
 * 
 *         return count_array
 */
  __pyx_slice__23 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__23);
  __Pyx_GIVEREF(__pyx_slice__23);

  /* "plastid/genomics/roitools.pyx":2771
 *             mask = numpy.frombuffer(self._position_mask,dtype=numpy.intc)
 *             if self.c_strand == reverse_strand:
 *                 mask = mask[::-1]             # <<<<<<<<<<<<<<
 * 
 *         return MaskedArray(counts,mask=mask.astype(bool),copy=copy)
 */
  __pyx_slice__24 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__24);
  __Pyx_GIVEREF(__pyx_slice__24);

  /* "plastid/genomics/roitools.pyx":2864
 *             chrom,middle,strand = ivcpat.search(inp).groups()
 *             segs = []
 *             for piece in middle.split("^"):             # <<<<<<<<<<<<<<
 *                 sstart,send = piece.split("-")
 *                 start = long(sstart)
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s__13); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "plastid/genomics/roitools.pyx":2865
 *             segs = []
 *             for piece in middle.split("^"):
 *                 sstart,send = piece.split("-")             # <<<<<<<<<<<<<<
 *                 start = long(sstart)
 *                 end = long(send)
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s__3); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "plastid/genomics/roitools.pyx":2917
 *             dict attr
 *             list frags = []
 *             list items = line.strip("\n").split("\t")             # <<<<<<<<<<<<<<
 * 
 *             #list column_formatters, frag_sizes, frag_offsets
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s__18); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s__17); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "plastid/genomics/roitools.pyx":2928
 *         if isinstance(extra_columns,int):
 *             if extra_columns < 0:
 *                 raise ValueError("Cannot make SegmentChain from BED input: if an integer, extra_columns must be non-negative.")             # <<<<<<<<<<<<<<
 *             num_extra_columns = extra_columns
 *             column_formatters = [("custom%s" % X,str) for X in range(extra_columns)]
 */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_Cannot_make_SegmentChain_from_BE); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "plastid/genomics/roitools.pyx":2935
 *             types = set([type(X) for X in extra_columns])
 *             if len(types) > 1:
 *                 raise ValueError("List of `extra_columns` contains mixed types. Cannot parse.")             # <<<<<<<<<<<<<<
 *             elif str in types:
 *                 column_formatters = [(X,str) for X in extra_columns]
 */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_List_of_extra_columns_contains_m); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "plastid/genomics/roitools.pyx":2940
 *             elif tuple in types:
 *                 if all([len(X) == 2 for X in extra_columns]) == False:
 *                     raise ValueError("Cannot make SegmentChain from BED input: if a list, extra_columns must be a list of tuples of (column_name,formatter_func)")             # <<<<<<<<<<<<<<
 *                 column_formatters = extra_columns
 *         else:
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_Cannot_make_SegmentChain_from_BE_2); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "plastid/genomics/roitools.pyx":2996
 *         # convert color to hex string
 *         try:
 *             attr["color"] = get_str_from_rgb255(tuple([int(X) for X in attr["color"].split(",")]))             # <<<<<<<<<<<<<<
 *         except ValueError:
 *             attr["color"] = "#000000"
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "plastid/genomics/roitools.pyx":3010
 *         # convert blocks to GenomicSegments
 *         num_frags    = int(attr["blocks"])
 *         frag_sizes   = [int(X) for X in attr["blocksizes"].strip(",").split(",")[:num_frags]]             # <<<<<<<<<<<<<<
 *         frag_offsets = [int(X) for X in attr["blockstarts"].strip(",").split(",")[:num_frags]]
 *         for i in range(0,num_frags):
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "plastid/genomics/roitools.pyx":3011
 *         num_frags    = int(attr["blocks"])
 *         frag_sizes   = [int(X) for X in attr["blocksizes"].strip(",").split(",")[:num_frags]]
 *         frag_offsets = [int(X) for X in attr["blockstarts"].strip(",").split(",")[:num_frags]]             # <<<<<<<<<<<<<<
 *         for i in range(0,num_frags):
 *             frag_start = chrom_start + frag_offsets[i]
 */
  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "plastid/genomics/roitools.pyx":3018
 * 
 *         # clean up attr
 *         for k in ("blocks","blocksizes","blockstarts"):             # <<<<<<<<<<<<<<
 *             attr.pop(k)
 * 
 */
  __pyx_tuple__37 = PyTuple_Pack(3, __pyx_n_s_blocks, __pyx_n_s_blocksizes, __pyx_n_s_blockstarts); if (unlikely(!__pyx_tuple__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "plastid/genomics/roitools.pyx":3039
 *         """
 *         cdef:
 *             list items = psl_line.strip().split("\t")             # <<<<<<<<<<<<<<
 *             list segs = []
 *             list block_starts, q_starts, t_starts
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s__17); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "plastid/genomics/roitools.pyx":3067
 *         #block_count           = int(items[17])
 * 
 *         block_sizes = [int(X) for X in items[18].strip(",").split(",")]             # <<<<<<<<<<<<<<
 *         q_starts    = [int(X) for X in items[19].strip(",").split(",")]
 *         t_starts    = [int(X) for X in items[20].strip(",").split(",")]
 */
  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "plastid/genomics/roitools.pyx":3068
 * 
 *         block_sizes = [int(X) for X in items[18].strip(",").split(",")]
 *         q_starts    = [int(X) for X in items[19].strip(",").split(",")]             # <<<<<<<<<<<<<<
 *         t_starts    = [int(X) for X in items[20].strip(",").split(",")]
 * 
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "plastid/genomics/roitools.pyx":3069
 *         block_sizes = [int(X) for X in items[18].strip(",").split(",")]
 *         q_starts    = [int(X) for X in items[19].strip(",").split(",")]
 *         t_starts    = [int(X) for X in items[20].strip(",").split(",")]             # <<<<<<<<<<<<<<
 * 
 *         attr["q_starts"] = q_starts
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "plastid/genomics/roitools.pyx":3250
 *             return transcript_richcmp(self,SegmentChain(other),cmpval) == true
 *         else:
 *             raise TypeError("SegmentChain eq/ineq/et c is only defined for other SegmentChains or GenomicSegments.")             # <<<<<<<<<<<<<<
 * 
 *     property cds_start:
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_SegmentChain_eq_ineq_et_c_is_onl); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "plastid/genomics/roitools.pyx":3658
 *         if len(cds_chain_temp) > 0:
 *             child_chain_attr  = copy.deepcopy(self.attr)
 *             child_chain_attr.pop("type")             # <<<<<<<<<<<<<<
 *             cds_positions = list(cds_chain_temp.get_position_list())
 * 
 */
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_n_s_type); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "plastid/genomics/roitools.pyx":3672
 *             stmp += cds_chain.as_gtf(feature_type="CDS",escape=escape,excludes=excludes)
 * 
 *             start_codon_chain = cds_chain_temp.get_subchain(0, 3)             # <<<<<<<<<<<<<<
 *             start_codon_chain.attr.update(child_chain_attr)
 *             stmp += start_codon_chain.as_gtf(feature_type="start_codon",escape=escape,excludes=excludes)
 */
  __pyx_tuple__48 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_3); if (unlikely(!__pyx_tuple__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "plastid/genomics/roitools.pyx":3773
 *             int n
 * 
 *         keys_to_pop = ("ID",)             # <<<<<<<<<<<<<<
 *         for k in keys_to_pop:
 *             if k in child_attr:
 */
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_n_s_ID); if (unlikely(!__pyx_tuple__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "plastid/genomics/roitools.pyx":3942
 * 
 *         attr["type"] = "mRNA" # default type for SegmentChain is "exon". We want to use "mRNA"
 *         attr.pop("thickstart")             # <<<<<<<<<<<<<<
 *         attr.pop("thickend")
 *         transcript.attr = attr
 */
  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_n_s_thickstart); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "plastid/genomics/roitools.pyx":3943
 *         attr["type"] = "mRNA" # default type for SegmentChain is "exon". We want to use "mRNA"
 *         attr.pop("thickstart")
 *         attr.pop("thickend")             # <<<<<<<<<<<<<<
 *         transcript.attr = attr
 * 
 */
  __pyx_tuple__52 = PyTuple_Pack(1, __pyx_n_s_thickend); if (unlikely(!__pyx_tuple__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":218
 *             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_tuple__53 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__53)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":222
 *             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_tuple__54 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__54)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":259
 *                 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_tuple__55 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__55)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.pxd":799
 * 
 *         if (end - f) - <int>(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_tuple__56 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_tuple__57 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__57)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "../../../../usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy/__init__.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_tuple__58 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "View.MemoryView":129
 * 
 *         if not self.ndim:
 *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if itemsize <= 0:
 */
  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__59)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "View.MemoryView":132
 * 
 *         if itemsize <= 0:
 *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(format, bytes):
 */
  __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__60)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "View.MemoryView":135
 * 
 *         if not isinstance(format, bytes):
 *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
 *         self._format = format  # keep a reference to the byte string
 *         self.format = self._format
 */
  __pyx_tuple__61 = PyTuple_Pack(1, __pyx_n_s_ASCII); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);

  /* "View.MemoryView":144
 * 
 *         if not self._shape:
 *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__62)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "View.MemoryView":172
 *             self.data = <char *>malloc(self.len)
 *             if not self.data:
 *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
 * 
 *             if self.dtype_is_object:
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "View.MemoryView":188
 *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
 *         if not (flags & bufmode):
 *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
 *         info.buf = self.data
 *         info.len = self.len
 */
  __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__64)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "View.MemoryView":447
 *             result = struct.unpack(self.view.format, bytesitem)
 *         except struct.error:
 *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
 *         else:
 *             if len(self.view.format) == 1:
 */
  __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__65)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "View.MemoryView":523
 *             if self.view.strides == NULL:
 * 
 *                 raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
 * 
 *             return tuple([stride for stride in self.view.strides[:self.view.ndim]])
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__66)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "View.MemoryView":531
 *         def __get__(self):
 *             if self.view.suboffsets == NULL:
 *                 return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
 * 
 *             return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
 */
  __pyx_tuple__67 = PyTuple_New(1); if (unlikely(!__pyx_tuple__67)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_INCREF(__pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  PyTuple_SET_ITEM(__pyx_tuple__67, 0, __pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_tuple__67);

  /* "View.MemoryView":640
 *         if item is Ellipsis:
 *             if not seen_ellipsis:
 *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
 *                 seen_ellipsis = True
 *             else:
 */
  __pyx_slice__68 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__68)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__68);
  __Pyx_GIVEREF(__pyx_slice__68);

  /* "View.MemoryView":643
 *                 seen_ellipsis = True
 *             else:
 *                 result.append(slice(None))             # <<<<<<<<<<<<<<
 *             have_slices = True
 *         else:
 */
  __pyx_slice__69 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__69)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__69);
  __Pyx_GIVEREF(__pyx_slice__69);

  /* "View.MemoryView":654
 *     nslices = ndim - len(result)
 *     if nslices:
 *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
 * 
 *     return have_slices or nslices, tuple(result)
 */
  __pyx_slice__70 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__70)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__70);
  __Pyx_GIVEREF(__pyx_slice__70);

  /* "View.MemoryView":661
 *     for suboffset in suboffsets[:ndim]:
 *         if suboffset >= 0:
 *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__71)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);

  /* "plastid/genomics/roitools.pyx":114
 * 
 * # to/from str
 * igvpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)")             # <<<<<<<<<<<<<<
 * segpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)\(([+-.])\)")
 * ivcpat = re.compile(r"([^:]*):([^(]+)\(([+-.])\)")
 */
  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_0_9_0_9); if (unlikely(!__pyx_tuple__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);

  /* "plastid/genomics/roitools.pyx":115
 * # to/from str
 * igvpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)")
 * segpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)\(([+-.])\)")             # <<<<<<<<<<<<<<
 * ivcpat = re.compile(r"([^:]*):([^(]+)\(([+-.])\)")
 * 
 */
  __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_0_9_0_9_2); if (unlikely(!__pyx_tuple__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "plastid/genomics/roitools.pyx":116
 * igvpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)")
 * segpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)\(([+-.])\)")
 * ivcpat = re.compile(r"([^:]*):([^(]+)\(([+-.])\)")             # <<<<<<<<<<<<<<
 * 
 * # compile time constants - __richcmp__ test
 */
  __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_s__74); if (unlikely(!__pyx_tuple__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);

  /* "plastid/genomics/roitools.pyx":144
 * #==============================================================================
 * 
 * NullSegment = GenomicSegment("NullChromosome",0,0,"\x00")             # <<<<<<<<<<<<<<
 * """Placeholder |GenomicSegment| for undefined objects"""
 * 
 */
  __pyx_tuple__76 = PyTuple_Pack(4, __pyx_n_s_NullChromosome, __pyx_int_0, __pyx_int_0, __pyx_kp_s__5); if (unlikely(!__pyx_tuple__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "plastid/genomics/roitools.pyx":151
 * #===============================================================================
 * 
 * def _get_attr(dict dtmp):             # <<<<<<<<<<<<<<
 *     ltmp=[]
 *     for k,v in sorted(dtmp.items()):
 */
  __pyx_tuple__77 = PyTuple_Pack(4, __pyx_n_s_dtmp, __pyx_n_s_ltmp, __pyx_n_s_k, __pyx_n_s_v); if (unlikely(!__pyx_tuple__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);
  __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_get_attr, 151, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":158
 *     return ",".join(ltmp)
 * 
 * def _format_segmentchain(SegmentChain segchain):             # <<<<<<<<<<<<<<
 *     """Formats a |SegmentChain| as a string, which when ``eval`` ed, should reconstruct the |SegmentChain|.
 *     Used for creating test datasets.
 */
  __pyx_tuple__79 = PyTuple_Pack(4, __pyx_n_s_segchain, __pyx_n_s_iv_ltmp, __pyx_n_s_iv, __pyx_n_s_stmp); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);
  __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_format_segmentchain, 158, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":179
 *     return stmp
 * 
 * def _format_transcript(Transcript tx):             # <<<<<<<<<<<<<<
 *     """Formats a |Transcript| as a string, which when ``eval`` ed, should reconstruct the |Transcript|.
 *     Used for creating test datasets.
 */
  __pyx_tuple__81 = PyTuple_Pack(4, __pyx_n_s_tx, __pyx_n_s_iv_ltmp, __pyx_n_s_iv, __pyx_n_s_stmp); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
  __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_format_transcript, 179, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":696
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Construct a |GenomicSegment| from its ``str()`` representation
 * 
 */
  __pyx_tuple__83 = PyTuple_Pack(7, __pyx_n_s_inp, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_chrom, __pyx_n_s_strand, __pyx_n_s_s_start, __pyx_n_s_s_end); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);
  __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(1, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_from_str, 696, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":845
 * 
 *     @staticmethod
 *     def from_igv_str(str loc_str, str strand="."):             # <<<<<<<<<<<<<<
 *         """Construct |GenomicSegment| from IGV location string
 * 
 */
  __pyx_tuple__85 = PyTuple_Pack(7, __pyx_n_s_loc_str, __pyx_n_s_strand, __pyx_n_s_chrom, __pyx_n_s_s_start, __pyx_n_s_s_end, __pyx_n_s_start, __pyx_n_s_end); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);
  __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__85, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_from_igv_str, 845, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":2834
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a string formatted by :py:meth:`SegmentChain.__str__`:
 * 
 */
  __pyx_tuple__87 = PyTuple_Pack(10, __pyx_n_s_inp, __pyx_n_s_chrom, __pyx_n_s_middle, __pyx_n_s_strand, __pyx_n_s_sstart, __pyx_n_s_send, __pyx_n_s_piece, __pyx_n_s_segs, __pyx_n_s_start, __pyx_n_s_end); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);
  __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_from_str, 2834, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":2873
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line, extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `BED`_ file.
 *         The `BED`_ line may contain 4 to 12 columns, per the specification.
 */
  __pyx_tuple__89 = PyTuple_Pack(29, __pyx_n_s_line, __pyx_n_s_extra_columns, __pyx_n_s_num_bed_columns, __pyx_n_s_num_extra_columns, __pyx_n_s_attr, __pyx_n_s_frags, __pyx_n_s_items, __pyx_n_s_column_formatters, __pyx_n_s_types, __pyx_n_s_chrom, __pyx_n_s_chrom_start, __pyx_n_s_chrom_end, __pyx_n_s_strand, __pyx_n_s_default_id, __pyx_n_s_bed_columns, __pyx_n_s_i, __pyx_n_s_tup, __pyx_n_s_key, __pyx_n_s_default, __pyx_n_s_func, __pyx_n_s_name_2, __pyx_n_s_formatter, __pyx_n_s_num_frags, __pyx_n_s_frag_sizes, __pyx_n_s_frag_offsets, __pyx_n_s_frag_start, __pyx_n_s_frag_end, __pyx_n_s_k, __pyx_n_s_X); if (unlikely(!__pyx_tuple__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);
  __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(2, 0, 29, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_from_bed, 2873, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3024
 * 
 *     @staticmethod
 *     def from_psl(psl_line):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `PSL`_ (BLAT) file
 * 
 */
  __pyx_tuple__91 = PyTuple_Pack(12, __pyx_n_s_psl_line, __pyx_n_s_items, __pyx_n_s_segs, __pyx_n_s_block_starts, __pyx_n_s_q_starts, __pyx_n_s_t_starts, __pyx_n_s_attr, __pyx_n_s_t_start, __pyx_n_s_block_size, __pyx_n_s_seg, __pyx_n_s_block_sizes, __pyx_n_s_X); if (unlikely(!__pyx_tuple__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);
  __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(1, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__91, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_from_psl, 3024, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3880
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line,extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |Transcript| from a BED line with 4 or more columns.
 *         `thickstart` and `thickend` columns, if present, are assumed to specify
 */
  __pyx_tuple__93 = PyTuple_Pack(8, __pyx_n_s_line, __pyx_n_s_extra_columns, __pyx_n_s_segchain, __pyx_n_s_segments, __pyx_n_s_attr, __pyx_n_s_transcript, __pyx_n_s_cds_genome_start, __pyx_n_s_cds_genome_end); if (unlikely(!__pyx_tuple__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);
  __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__93, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_from_bed, 3880, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "plastid/genomics/roitools.pyx":3949
 * 
 *     @staticmethod
 *     def from_psl(str psl_line):             # <<<<<<<<<<<<<<
 *         cdef:
 *             Transcript transcript = Transcript()
 */
  __pyx_tuple__95 = PyTuple_Pack(4, __pyx_n_s_psl_line, __pyx_n_s_transcript, __pyx_n_s_segchain, __pyx_n_s_attr); if (unlikely(!__pyx_tuple__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);
  __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__95, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_homeroot_joshua_projects_plasti, __pyx_n_s_from_psl, 3949, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "View.MemoryView":278
 *         return self.name
 * 
 * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")
 */
  __pyx_tuple__97 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__97)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);

  /* "View.MemoryView":279
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
 * cdef indirect = Enum("<strided and indirect>")
 * 
 */
  __pyx_tuple__98 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__98)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__98);
  __Pyx_GIVEREF(__pyx_tuple__98);

  /* "View.MemoryView":280
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__99 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__99)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);

  /* "View.MemoryView":283
 * 
 * 
 * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")
 * 
 */
  __pyx_tuple__100 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__100)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__100);
  __Pyx_GIVEREF(__pyx_tuple__100);

  /* "View.MemoryView":284
 * 
 * cdef contiguous = Enum("<contiguous and direct>")
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_tuple__101 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__101)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type;
  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_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_9 = PyInt_FromLong(9); if (unlikely(!__pyx_int_9)) {__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_11 = PyInt_FromLong(11); if (unlikely(!__pyx_int_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initroitools(void); /*proto*/
PyMODINIT_FUNC initroitools(void)
#else
PyMODINIT_FUNC PyInit_roitools(void); /*proto*/
PyMODINIT_FUNC PyInit_roitools(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __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_roitools(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_Coroutine_USED
  if (__pyx_Coroutine_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
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_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("roitools", __pyx_methods, __pyx_k_This_module_defines_object_types, 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;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__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 (PyObject_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 (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_plastid__genomics__roitools) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__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, "plastid.genomics.roitools")) {
      if (unlikely(PyDict_SetItemString(modules, "plastid.genomics.roitools", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  __pyx_v_7plastid_8genomics_8roitools_NullSegment = ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)Py_None); Py_INCREF(Py_None);
  __pyx_v_7plastid_8genomics_8roitools_hash_template = Py_None; Py_INCREF(Py_None);
  __pyx_v_7plastid_8genomics_8roitools_mask_template = Py_None; Py_INCREF(Py_None);
  generic = Py_None; Py_INCREF(Py_None);
  strided = Py_None; Py_INCREF(Py_None);
  indirect = Py_None; Py_INCREF(Py_None);
  contiguous = Py_None; Py_INCREF(Py_None);
  indirect_contiguous = Py_None; Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  if (__Pyx_ExportVoidPtr(__pyx_n_s_NullSegment, (void *)&__pyx_v_7plastid_8genomics_8roitools_NullSegment, "struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("strand_to_str", (void (*)(void))__pyx_f_7plastid_8genomics_8roitools_strand_to_str, "PyObject *(enum __pyx_t_7plastid_8genomics_8c_common_Strand)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("str_to_strand", (void (*)(void))__pyx_f_7plastid_8genomics_8roitools_str_to_strand, "enum __pyx_t_7plastid_8genomics_8c_common_Strand (PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("positions_to_segments", (void (*)(void))__pyx_f_7plastid_8genomics_8roitools_positions_to_segments, "PyObject *(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("positionlist_to_segments", (void (*)(void))__pyx_f_7plastid_8genomics_8roitools_positionlist_to_segments, "PyObject *(PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("add_three_for_stop_codon", (void (*)(void))__pyx_f_7plastid_8genomics_8roitools_add_three_for_stop_codon, "struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Type init code ---*/
  __pyx_vtabptr_7plastid_8genomics_8roitools_GenomicSegment = &__pyx_vtable_7plastid_8genomics_8roitools_GenomicSegment;
  __pyx_vtable_7plastid_8genomics_8roitools_GenomicSegment.contains = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, int __pyx_skip_dispatch))__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_contains;
  __pyx_vtable_7plastid_8genomics_8roitools_GenomicSegment.overlaps = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, int __pyx_skip_dispatch))__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_overlaps;
  __pyx_vtable_7plastid_8genomics_8roitools_GenomicSegment._cmp_helper = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, int, int __pyx_skip_dispatch))__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment__cmp_helper;
  __pyx_vtable_7plastid_8genomics_8roitools_GenomicSegment.as_igv_str = (PyObject *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *, int __pyx_skip_dispatch))__pyx_f_7plastid_8genomics_8roitools_14GenomicSegment_as_igv_str;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools_GenomicSegment) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools_GenomicSegment.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7plastid_8genomics_8roitools_GenomicSegment, "__len__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7plastid_8genomics_8roitools_14GenomicSegment_14__len__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7plastid_8genomics_8roitools_14GenomicSegment_14__len__.doc = __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_14__len__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7plastid_8genomics_8roitools_14GenomicSegment_14__len__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7plastid_8genomics_8roitools_GenomicSegment, "__contains__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__.doc = __pyx_doc_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7plastid_8genomics_8roitools_14GenomicSegment_20__contains__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_7plastid_8genomics_8roitools_GenomicSegment.tp_dict, __pyx_vtabptr_7plastid_8genomics_8roitools_GenomicSegment) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "GenomicSegment", (PyObject *)&__pyx_type_7plastid_8genomics_8roitools_GenomicSegment) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment = &__pyx_type_7plastid_8genomics_8roitools_GenomicSegment;
  __pyx_vtabptr_7plastid_8genomics_8roitools_SegmentChain = &__pyx_vtable_7plastid_8genomics_8roitools_SegmentChain;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_add_segments = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, PyObject *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_add_segments;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain._set_segments = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, PyObject *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain__set_segments;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain._set_masks = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, PyObject *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain__set_masks;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_reset_masks = (void (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_reset_masks;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain._get_inverse_hash = (PyObject *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain__get_inverse_hash;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_shares_segments_with = (PyObject *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_shares_segments_with;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_covers = (enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_covers;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_unstranded_overlaps = (enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_unstranded_overlaps;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_overlaps = (enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_overlaps;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_antisense_overlaps = (enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_antisense_overlaps;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_contains = (enum __pyx_t_7plastid_8genomics_8c_common_ExBool (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_contains;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_get_position_list = (PyObject *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_list;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_get_position_set = (PyObject *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_set;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_get_position_array = (PyArrayObject *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, int))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_position_array;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.get_masked_position_set = (PyObject *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, int __pyx_skip_dispatch))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_get_masked_position_set;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_get_genomic_coordinate = (long (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, long, int))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_genomic_coordinate;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_get_segmentchain_coordinate = (long (*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, long, int))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_segmentchain_coordinate;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.c_get_subchain = (struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, long, long, int))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_c_get_subchain;
  __pyx_vtable_7plastid_8genomics_8roitools_SegmentChain.get_antisense = (struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *(*)(struct __pyx_obj_7plastid_8genomics_8roitools_SegmentChain *, int __pyx_skip_dispatch))__pyx_f_7plastid_8genomics_8roitools_12SegmentChain_get_antisense;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools_SegmentChain) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools_SegmentChain.tp_print = 0;
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7plastid_8genomics_8roitools_SegmentChain, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_18__str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_18__str__.doc = __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_18__str__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_18__str__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7plastid_8genomics_8roitools_SegmentChain, "__getitem__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__.doc = __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_20__getitem__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7plastid_8genomics_8roitools_SegmentChain, "__iter__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_22__iter__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_22__iter__.doc = __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_22__iter__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_22__iter__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7plastid_8genomics_8roitools_SegmentChain, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_24__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_24__next__.doc = __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_24__next__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_24__next__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7plastid_8genomics_8roitools_SegmentChain, "__len__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_28__len__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_28__len__.doc = __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_28__len__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_28__len__;
    }
  }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_7plastid_8genomics_8roitools_SegmentChain, "__contains__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_30__contains__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_30__contains__.doc = __pyx_doc_7plastid_8genomics_8roitools_12SegmentChain_30__contains__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_7plastid_8genomics_8roitools_12SegmentChain_30__contains__;
    }
  }
  #endif
  if (__Pyx_SetVtable(__pyx_type_7plastid_8genomics_8roitools_SegmentChain.tp_dict, __pyx_vtabptr_7plastid_8genomics_8roitools_SegmentChain) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "SegmentChain", (PyObject *)&__pyx_type_7plastid_8genomics_8roitools_SegmentChain) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain = &__pyx_type_7plastid_8genomics_8roitools_SegmentChain;
  __pyx_vtabptr_7plastid_8genomics_8roitools_Transcript = &__pyx_vtable_7plastid_8genomics_8roitools_Transcript;
  __pyx_vtable_7plastid_8genomics_8roitools_Transcript.__pyx_base = *__pyx_vtabptr_7plastid_8genomics_8roitools_SegmentChain;
  __pyx_vtable_7plastid_8genomics_8roitools_Transcript._update_cds = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *))__pyx_f_7plastid_8genomics_8roitools_10Transcript__update_cds;
  __pyx_vtable_7plastid_8genomics_8roitools_Transcript._update_from_cds_start = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *))__pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_start;
  __pyx_vtable_7plastid_8genomics_8roitools_Transcript._update_from_cds_end = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *))__pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_end;
  __pyx_vtable_7plastid_8genomics_8roitools_Transcript._update_from_cds_genome_start = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *))__pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_genome_start;
  __pyx_vtable_7plastid_8genomics_8roitools_Transcript._update_from_cds_genome_end = (int (*)(struct __pyx_obj_7plastid_8genomics_8roitools_Transcript *))__pyx_f_7plastid_8genomics_8roitools_10Transcript__update_from_cds_genome_end;
  __pyx_type_7plastid_8genomics_8roitools_Transcript.tp_base = __pyx_ptype_7plastid_8genomics_8roitools_SegmentChain;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools_Transcript) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools_Transcript.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_7plastid_8genomics_8roitools_Transcript.tp_dict, __pyx_vtabptr_7plastid_8genomics_8roitools_Transcript) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "Transcript", (PyObject *)&__pyx_type_7plastid_8genomics_8roitools_Transcript) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7plastid_8genomics_8roitools_Transcript = &__pyx_type_7plastid_8genomics_8roitools_Transcript;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed.tp_print = 0;
  __pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed = &__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct__as_bed;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr.tp_print = 0;
  __pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr = &__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr.tp_print = 0;
  __pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr = &__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_2_genexpr;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr.tp_print = 0;
  __pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr = &__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_3_genexpr;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr.tp_print = 0;
  __pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr = &__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_4_genexpr;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl.tp_print = 0;
  __pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl = &__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_5_as_psl;
  if (PyType_Ready(&__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr.tp_print = 0;
  __pyx_ptype_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr = &__pyx_type_7plastid_8genomics_8roitools___pyx_scope_struct_6_genexpr;
  if (PyType_Ready(&__pyx_type___pyx_array) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type___pyx_array.tp_print = 0;
  __pyx_array_type = &__pyx_type___pyx_array;
  if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type___pyx_MemviewEnum.tp_print = 0;
  __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
  __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
  __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
  __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
  __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
  __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
  __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
  __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
  __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
  if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type___pyx_memoryview.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
  __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
  __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
  __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
  __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
  __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
  if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type___pyx_memoryviewslice.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
  /*--- Type import code ---*/
  __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[5]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_5array_array = __Pyx_ImportType("array", "array", sizeof(arrayobject), 0); if (unlikely(!__pyx_ptype_7cpython_5array_array)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __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[3]; __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[3]; __pyx_lineno = 168; __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[3]; __pyx_lineno = 172; __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[3]; __pyx_lineno = 181; __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[3]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif

  /* "plastid/genomics/roitools.pyx":80
 * 
 * 
 * import re             # <<<<<<<<<<<<<<
 * import copy
 * import warnings
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_re, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":81
 * 
 * import re
 * import copy             # <<<<<<<<<<<<<<
 * import warnings
 * import array
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_copy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_copy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":82
 * import re
 * import copy
 * import warnings             # <<<<<<<<<<<<<<
 * import array
 * import numpy
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_warnings, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":83
 * import copy
 * import warnings
 * import array             # <<<<<<<<<<<<<<
 * import numpy
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_array, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_array, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":84
 * import warnings
 * import array
 * import numpy             # <<<<<<<<<<<<<<
 * 
 * cimport numpy
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":89
 * 
 * 
 * from numpy.ma import MaskedArray as MaskedArray             # <<<<<<<<<<<<<<
 * from Bio.SeqRecord import SeqRecord
 * from Bio.Seq import Seq
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_MaskedArray);
  __Pyx_GIVEREF(__pyx_n_s_MaskedArray);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_MaskedArray);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy_ma, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __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_ImportFrom(__pyx_t_2, __pyx_n_s_MaskedArray); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_MaskedArray, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __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;

  /* "plastid/genomics/roitools.pyx":90
 * 
 * from numpy.ma import MaskedArray as MaskedArray
 * from Bio.SeqRecord import SeqRecord             # <<<<<<<<<<<<<<
 * from Bio.Seq import Seq
 * from Bio.Alphabet import generic_dna
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_SeqRecord);
  __Pyx_GIVEREF(__pyx_n_s_SeqRecord);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_SeqRecord);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_Bio_SeqRecord, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_SeqRecord); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_SeqRecord, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":91
 * from numpy.ma import MaskedArray as MaskedArray
 * from Bio.SeqRecord import SeqRecord
 * from Bio.Seq import Seq             # <<<<<<<<<<<<<<
 * from Bio.Alphabet import generic_dna
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_Seq);
  __Pyx_GIVEREF(__pyx_n_s_Seq);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Seq);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_Bio_Seq, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __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_ImportFrom(__pyx_t_2, __pyx_n_s_Seq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Seq, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __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;

  /* "plastid/genomics/roitools.pyx":92
 * from Bio.SeqRecord import SeqRecord
 * from Bio.Seq import Seq
 * from Bio.Alphabet import generic_dna             # <<<<<<<<<<<<<<
 * 
 * from plastid.util.services.exceptions import DataWarning
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_generic_dna);
  __Pyx_GIVEREF(__pyx_n_s_generic_dna);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_generic_dna);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_Bio_Alphabet, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_generic_dna); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_generic_dna, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":94
 * from Bio.Alphabet import generic_dna
 * 
 * from plastid.util.services.exceptions import DataWarning             # <<<<<<<<<<<<<<
 * from plastid.util.services.decorators import deprecated
 * from plastid.plotting.colors import get_str_from_rgb255, get_str_from_rgb, get_rgb255
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_DataWarning);
  __Pyx_GIVEREF(__pyx_n_s_DataWarning);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_DataWarning);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_plastid_util_services_exceptions, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __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_ImportFrom(__pyx_t_2, __pyx_n_s_DataWarning); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DataWarning, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __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;

  /* "plastid/genomics/roitools.pyx":95
 * 
 * from plastid.util.services.exceptions import DataWarning
 * from plastid.util.services.decorators import deprecated             # <<<<<<<<<<<<<<
 * from plastid.plotting.colors import get_str_from_rgb255, get_str_from_rgb, get_rgb255
 * from plastid.readers.gff_tokens import make_GFF3_tokens, \
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_deprecated);
  __Pyx_GIVEREF(__pyx_n_s_deprecated);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_deprecated);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_plastid_util_services_decorators, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_deprecated); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_deprecated, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":96
 * from plastid.util.services.exceptions import DataWarning
 * from plastid.util.services.decorators import deprecated
 * from plastid.plotting.colors import get_str_from_rgb255, get_str_from_rgb, get_rgb255             # <<<<<<<<<<<<<<
 * from plastid.readers.gff_tokens import make_GFF3_tokens, \
 *                                        make_GTF2_tokens
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_get_str_from_rgb255);
  __Pyx_GIVEREF(__pyx_n_s_get_str_from_rgb255);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_get_str_from_rgb255);
  __Pyx_INCREF(__pyx_n_s_get_str_from_rgb);
  __Pyx_GIVEREF(__pyx_n_s_get_str_from_rgb);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_get_str_from_rgb);
  __Pyx_INCREF(__pyx_n_s_get_rgb255);
  __Pyx_GIVEREF(__pyx_n_s_get_rgb255);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_get_rgb255);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_plastid_plotting_colors, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __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_ImportFrom(__pyx_t_2, __pyx_n_s_get_str_from_rgb255); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_str_from_rgb255, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_str_from_rgb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_str_from_rgb, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_get_rgb255); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_rgb255, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __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;

  /* "plastid/genomics/roitools.pyx":97
 * from plastid.util.services.decorators import deprecated
 * from plastid.plotting.colors import get_str_from_rgb255, get_str_from_rgb, get_rgb255
 * from plastid.readers.gff_tokens import make_GFF3_tokens, \             # <<<<<<<<<<<<<<
 *                                        make_GTF2_tokens
 * 
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_make_GFF3_tokens);
  __Pyx_GIVEREF(__pyx_n_s_make_GFF3_tokens);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_make_GFF3_tokens);
  __Pyx_INCREF(__pyx_n_s_make_GTF2_tokens);
  __Pyx_GIVEREF(__pyx_n_s_make_GTF2_tokens);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_make_GTF2_tokens);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_plastid_readers_gff_tokens, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_make_GFF3_tokens); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_GFF3_tokens, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_make_GTF2_tokens); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_GTF2_tokens, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":110
 * #===============================================================================
 * 
 * cdef hash_template = array.array('l',[]) # c signed long / python int             # <<<<<<<<<<<<<<
 * cdef mask_template = array.array('i',[]) # TODO: change to c unsigned char / python int
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __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 = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_l);
  __Pyx_GIVEREF(__pyx_n_s_l);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_l);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7cpython_5array_array), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_XGOTREF(__pyx_v_7plastid_8genomics_8roitools_hash_template);
  __Pyx_DECREF_SET(__pyx_v_7plastid_8genomics_8roitools_hash_template, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":111
 * 
 * cdef hash_template = array.array('l',[]) # c signed long / python int
 * cdef mask_template = array.array('i',[]) # TODO: change to c unsigned char / python int             # <<<<<<<<<<<<<<
 * 
 * # to/from str
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __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 = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_i);
  __Pyx_GIVEREF(__pyx_n_s_i);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_i);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7cpython_5array_array), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_XGOTREF(__pyx_v_7plastid_8genomics_8roitools_mask_template);
  __Pyx_DECREF_SET(__pyx_v_7plastid_8genomics_8roitools_mask_template, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":114
 * 
 * # to/from str
 * igvpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)")             # <<<<<<<<<<<<<<
 * segpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)\(([+-.])\)")
 * ivcpat = re.compile(r"([^:]*):([^(]+)\(([+-.])\)")
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __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_PyObject_Call(__pyx_t_2, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_igvpat, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":115
 * # to/from str
 * igvpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)")
 * segpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)\(([+-.])\)")             # <<<<<<<<<<<<<<
 * ivcpat = re.compile(r"([^:]*):([^(]+)\(([+-.])\)")
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); 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_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_segpat, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":116
 * igvpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)")
 * segpat = re.compile(r"([^:]*):([0-9]+)-([0-9]+)\(([+-.])\)")
 * ivcpat = re.compile(r"([^:]*):([^(]+)\(([+-.])\)")             # <<<<<<<<<<<<<<
 * 
 * # compile time constants - __richcmp__ test
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __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_PyObject_Call(__pyx_t_2, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ivcpat, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":127
 * 
 * # numeric types
 * INT    = numpy.int             # <<<<<<<<<<<<<<
 * FLOAT  = numpy.float
 * DOUBLE = numpy.double
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_INT, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":128
 * # numeric types
 * INT    = numpy.int
 * FLOAT  = numpy.float             # <<<<<<<<<<<<<<
 * DOUBLE = numpy.double
 * LONG   = numpy.long
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); 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_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float); 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;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_FLOAT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":129
 * INT    = numpy.int
 * FLOAT  = numpy.float
 * DOUBLE = numpy.double             # <<<<<<<<<<<<<<
 * LONG   = numpy.long
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); 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_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_double); 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_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DOUBLE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "plastid/genomics/roitools.pyx":130
 * FLOAT  = numpy.float
 * DOUBLE = numpy.double
 * LONG   = numpy.long             # <<<<<<<<<<<<<<
 * 
 * ctypedef numpy.int_t    INT_t
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_numpy); 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_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_long); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_LONG, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":144
 * #==============================================================================
 * 
 * NullSegment = GenomicSegment("NullChromosome",0,0,"\x00")             # <<<<<<<<<<<<<<
 * """Placeholder |GenomicSegment| for undefined objects"""
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment), __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(((PyObject *)__pyx_v_7plastid_8genomics_8roitools_NullSegment));
  __Pyx_DECREF_SET(__pyx_v_7plastid_8genomics_8roitools_NullSegment, ((struct __pyx_obj_7plastid_8genomics_8roitools_GenomicSegment *)__pyx_t_1));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":151
 * #===============================================================================
 * 
 * def _get_attr(dict dtmp):             # <<<<<<<<<<<<<<
 *     ltmp=[]
 *     for k,v in sorted(dtmp.items()):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_1_get_attr, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_attr, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":158
 *     return ",".join(ltmp)
 * 
 * def _format_segmentchain(SegmentChain segchain):             # <<<<<<<<<<<<<<
 *     """Formats a |SegmentChain| as a string, which when ``eval`` ed, should reconstruct the |SegmentChain|.
 *     Used for creating test datasets.
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_3_format_segmentchain, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_format_segmentchain, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":179
 *     return stmp
 * 
 * def _format_transcript(Transcript tx):             # <<<<<<<<<<<<<<
 *     """Formats a |Transcript| as a string, which when ``eval`` ed, should reconstruct the |Transcript|.
 *     Used for creating test datasets.
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_5_format_transcript, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_format_transcript, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":696
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Construct a |GenomicSegment| from its ``str()`` representation
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_14GenomicSegment_9from_str, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":695
 *         return "%s:%s-%s(%s)" % (self.chrom, self.start, self.end, self.strand)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_str(str inp):
 *         """Construct a |GenomicSegment| from its ``str()`` representation
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment->tp_dict, __pyx_n_s_from_str, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment);

  /* "plastid/genomics/roitools.pyx":696
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Construct a |GenomicSegment| from its ``str()`` representation
 * 
 */
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment, __pyx_n_s_from_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":695
 *         return "%s:%s-%s(%s)" % (self.chrom, self.start, self.end, self.strand)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_str(str inp):
 *         """Construct a |GenomicSegment| from its ``str()`` representation
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment->tp_dict, __pyx_n_s_from_str, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment);

  /* "plastid/genomics/roitools.pyx":845
 * 
 *     @staticmethod
 *     def from_igv_str(str loc_str, str strand="."):             # <<<<<<<<<<<<<<
 *         """Construct |GenomicSegment| from IGV location string
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_14GenomicSegment_29from_igv_str, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":844
 *         return "%s:%s-%s" % (self.chrom, self.start+1, self.end+1)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_igv_str(str loc_str, str strand="."):
 *         """Construct |GenomicSegment| from IGV location string
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment->tp_dict, __pyx_n_s_from_igv_str, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment);

  /* "plastid/genomics/roitools.pyx":845
 * 
 *     @staticmethod
 *     def from_igv_str(str loc_str, str strand="."):             # <<<<<<<<<<<<<<
 *         """Construct |GenomicSegment| from IGV location string
 * 
 */
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment, __pyx_n_s_from_igv_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":844
 *         return "%s:%s-%s" % (self.chrom, self.start+1, self.end+1)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_igv_str(str loc_str, str strand="."):
 *         """Construct |GenomicSegment| from IGV location string
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment->tp_dict, __pyx_n_s_from_igv_str, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_GenomicSegment);

  /* "plastid/genomics/roitools.pyx":1963
 * 
 *     # TODO: test optimality
 *     def as_gff3(self, str feature_type=None, bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format a length-1 |SegmentChain| as a line of `GFF3`_ output.
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k__15 = ((PyObject*)__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2055
 * 
 *     # TODO: optimize
 *     def as_gtf(self, str feature_type=None, bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format |SegmentChain| as a block of `GTF2`_ output.
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k__19 = ((PyObject*)__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":2834
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a string formatted by :py:meth:`SegmentChain.__str__`:
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_12SegmentChain_95from_str, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":2833
 *         return ">%s\n%s\n" % (self.get_name(),self.get_sequence(genome,stranded=stranded))
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_str(str inp):
 *         """Create a |SegmentChain| from a string formatted by :py:meth:`SegmentChain.__str__`:
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain->tp_dict, __pyx_n_s_from_str, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain);

  /* "plastid/genomics/roitools.pyx":2834
 * 
 *     @staticmethod
 *     def from_str(str inp):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a string formatted by :py:meth:`SegmentChain.__str__`:
 * 
 */
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain, __pyx_n_s_from_str); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":2833
 *         return ">%s\n%s\n" % (self.get_name(),self.get_sequence(genome,stranded=stranded))
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_str(str inp):
 *         """Create a |SegmentChain| from a string formatted by :py:meth:`SegmentChain.__str__`:
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain->tp_dict, __pyx_n_s_from_str, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain);

  /* "plastid/genomics/roitools.pyx":2873
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line, extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `BED`_ file.
 *         The `BED`_ line may contain 4 to 12 columns, per the specification.
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_12SegmentChain_97from_bed, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":2872
 * 
 *     # TODO: optimize
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_bed(str line, extra_columns=0):
 *         """Create a |SegmentChain| from a line from a `BED`_ file.
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain->tp_dict, __pyx_n_s_from_bed, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain);

  /* "plastid/genomics/roitools.pyx":2873
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line, extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `BED`_ file.
 *         The `BED`_ line may contain 4 to 12 columns, per the specification.
 */
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain, __pyx_n_s_from_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":2872
 * 
 *     # TODO: optimize
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_bed(str line, extra_columns=0):
 *         """Create a |SegmentChain| from a line from a `BED`_ file.
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain->tp_dict, __pyx_n_s_from_bed, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain);

  /* "plastid/genomics/roitools.pyx":3024
 * 
 *     @staticmethod
 *     def from_psl(psl_line):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `PSL`_ (BLAT) file
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_12SegmentChain_99from_psl, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3023
 *         return SegmentChain(*frags,**attr)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_psl(psl_line):
 *         """Create a |SegmentChain| from a line from a `PSL`_ (BLAT) file
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain->tp_dict, __pyx_n_s_from_psl, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain);

  /* "plastid/genomics/roitools.pyx":3024
 * 
 *     @staticmethod
 *     def from_psl(psl_line):             # <<<<<<<<<<<<<<
 *         """Create a |SegmentChain| from a line from a `PSL`_ (BLAT) file
 * 
 */
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain, __pyx_n_s_from_psl); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3023
 *         return SegmentChain(*frags,**attr)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_psl(psl_line):
 *         """Create a |SegmentChain| from a line from a `PSL`_ (BLAT) file
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain->tp_dict, __pyx_n_s_from_psl, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_SegmentChain);

  /* "plastid/genomics/roitools.pyx":3582
 *             return SegmentChain()
 * 
 *     def as_gtf(self, str feature_type="exon", bint escape=True, list excludes=[]):             # <<<<<<<<<<<<<<
 *         """Format `self` as a `GTF2`_ block. |GenomicSegments| are formatted
 *         as `GTF2`_ `'exon'` features. Coding regions, if peresent, are formatted
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k__46 = ((PyObject*)__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3682
 *         return stmp
 * 
 *     def as_gff3(self, bint escape=True, list excludes=[], str rna_type="mRNA"):             # <<<<<<<<<<<<<<
 *         """Format a |Transcript| as a block of `GFF3`_ output, following
 *         the schema set out in the `Sequence Ontology (SO) v2.53 <http://www.sequenceontology.org/browser/>`_
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k__49 = ((PyObject*)__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "plastid/genomics/roitools.pyx":3880
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line,extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |Transcript| from a BED line with 4 or more columns.
 *         `thickstart` and `thickend` columns, if present, are assumed to specify
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_10Transcript_29from_bed, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3879
 * 
 *     # TODO: optimize
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_bed(str line,extra_columns=0):
 *         """Create a |Transcript| from a BED line with 4 or more columns.
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript->tp_dict, __pyx_n_s_from_bed, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_Transcript);

  /* "plastid/genomics/roitools.pyx":3880
 *     # TODO: optimize
 *     @staticmethod
 *     def from_bed(str line,extra_columns=0):             # <<<<<<<<<<<<<<
 *         """Create a |Transcript| from a BED line with 4 or more columns.
 *         `thickstart` and `thickend` columns, if present, are assumed to specify
 */
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript, __pyx_n_s_from_bed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3879
 * 
 *     # TODO: optimize
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_bed(str line,extra_columns=0):
 *         """Create a |Transcript| from a BED line with 4 or more columns.
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript->tp_dict, __pyx_n_s_from_bed, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_Transcript);

  /* "plastid/genomics/roitools.pyx":3949
 * 
 *     @staticmethod
 *     def from_psl(str psl_line):             # <<<<<<<<<<<<<<
 *         cdef:
 *             Transcript transcript = Transcript()
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7plastid_8genomics_8roitools_10Transcript_31from_psl, NULL, __pyx_n_s_plastid_genomics_roitools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3948
 *         return transcript
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_psl(str psl_line):
 *         cdef:
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript->tp_dict, __pyx_n_s_from_psl, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_Transcript);

  /* "plastid/genomics/roitools.pyx":3949
 * 
 *     @staticmethod
 *     def from_psl(str psl_line):             # <<<<<<<<<<<<<<
 *         cdef:
 *             Transcript transcript = Transcript()
 */
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript, __pyx_n_s_from_psl); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "plastid/genomics/roitools.pyx":3948
 *         return transcript
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def from_psl(str psl_line):
 *         cdef:
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_7plastid_8genomics_8roitools_Transcript->tp_dict, __pyx_n_s_from_psl, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_7plastid_8genomics_8roitools_Transcript);

  /* "plastid/genomics/roitools.pyx":1
 * #!/usr/bin/env python             # <<<<<<<<<<<<<<
 * """This module defines object types that describe features in a genome or contig.
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "View.MemoryView":205
 *         info.obj = self
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(array self):
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_array_type);

  /* "View.MemoryView":278
 *         return self.name
 * 
 * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__97, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(generic);
  __Pyx_DECREF_SET(generic, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":279
 * 
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
 * cdef indirect = Enum("<strided and indirect>")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__98, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(strided);
  __Pyx_DECREF_SET(strided, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":280
 * cdef generic = Enum("<strided and direct or indirect>")
 * cdef strided = Enum("<strided and direct>") # default
 * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__99, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(indirect);
  __Pyx_DECREF_SET(indirect, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":283
 * 
 * 
 * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__100, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(contiguous);
  __Pyx_DECREF_SET(contiguous, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":284
 * 
 * cdef contiguous = Enum("<contiguous and direct>")
 * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__101, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XGOTREF(indirect_contiguous);
  __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "View.MemoryView":498
 *         info.obj = self
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_memoryview_type);

  /* "View.MemoryView":954
 *             return self.from_object
 * 
 *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_memoryviewslice_type);

  /* "View.MemoryView":1364
 * 
 * @cname('__pyx_memoryview__slice_assign_scalar')
 * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
 *                               Py_ssize_t *strides, int ndim,
 *                               size_t itemsize, void *item) nogil:
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init plastid.genomics.roitools", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init plastid.genomics.roitools");
  }
  __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

static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
}
static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (likely(Py_TYPE(obj) == type)) return 1;
        #if PY_MAJOR_VERSION == 2
        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(PyObject_TypeCheck(obj, type))) return 1;
    }
    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
    return 0;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(PyObject_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_O | METH_NOARGS);
    }
#endif
    return 0;
}

static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    args = PyTuple_New(1);
    if (unlikely(!args)) goto bad;
    Py_INCREF(self);
    PyTuple_SET_ITEM(args, 0, self);
#else
    args = PyTuple_Pack(1, self);
    if (unlikely(!args)) goto bad;
#endif
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    Py_DECREF(args);
bad:
    return result;
}

static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d);
    else
        return PyDict_Items(d);
}

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%.1s 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;
}

#if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject* args = PyTuple_Pack(1, arg);
    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

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,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

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,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

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;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (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 = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || 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) {
    if (unlikely(!type)) {
        PyErr_SetString(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 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, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || 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 {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return -1;
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS && PY_MAJOR_VERSION >= 3
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

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 (PyType_Check(type)) {
#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;
        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;
        }
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
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 *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            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 = PyObject_Call(type, args, NULL);
            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 PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else 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) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        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);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#endif
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #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);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_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,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static void __Pyx_RaiseBufferIndexError(int axis) {
  PyErr_Format(PyExc_IndexError,
     "Out of bounds on buffer access (axis %d)", axis);
}

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)
        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;
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break;
      }
      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;
        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 != ')') {
        switch (*ts) {
            case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
            default:  break;
        }
        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 '\r':
      case '\n':
        ++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':
        {
          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;
          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 '}':
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          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;
        }
      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 'p':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
            ctx->enc_packmode == ctx->new_packmode) {
          ctx->enc_count += ctx->new_count;
          ctx->new_count = 1;
          got_Z = 0;
          ++ts;
          break;
        }
      case 's':
        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 int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
                        int ndim,
                        __Pyx_memviewslice *memviewslice,
                        int memview_is_new_reference)
{
    __Pyx_RefNannyDeclarations
    int i, retval=-1;
    Py_buffer *buf = &memview->view;
    __Pyx_RefNannySetupContext("init_memviewslice", 0);
    if (!buf) {
        PyErr_SetString(PyExc_ValueError,
            "buf is NULL.");
        goto fail;
    } else if (memviewslice->memview || memviewslice->data) {
        PyErr_SetString(PyExc_ValueError,
            "memviewslice is already initialized!");
        goto fail;
    }
    if (buf->strides) {
        for (i = 0; i < ndim; i++) {
            memviewslice->strides[i] = buf->strides[i];
        }
    } else {
        Py_ssize_t stride = buf->itemsize;
        for (i = ndim - 1; i >= 0; i--) {
            memviewslice->strides[i] = stride;
            stride *= buf->shape[i];
        }
    }
    for (i = 0; i < ndim; i++) {
        memviewslice->shape[i]   = buf->shape[i];
        if (buf->suboffsets) {
            memviewslice->suboffsets[i] = buf->suboffsets[i];
        } else {
            memviewslice->suboffsets[i] = -1;
        }
    }
    memviewslice->memview = memview;
    memviewslice->data = (char *)buf->buf;
    if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
        Py_INCREF(memview);
    }
    retval = 0;
    goto no_fail;
fail:
    memviewslice->memview = 0;
    memviewslice->data = 0;
    retval = -1;
no_fail:
    __Pyx_RefNannyFinishContext();
    return retval;
}
static CYTHON_INLINE void __pyx_fatalerror(const char *fmt, ...) {
    va_list vargs;
    char msg[200];
#ifdef HAVE_STDARG_PROTOTYPES
    va_start(vargs, fmt);
#else
    va_start(vargs);
#endif
    vsnprintf(msg, 200, fmt, vargs);
    Py_FatalError(msg);
    va_end(vargs);
}
static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
                                   PyThread_type_lock lock)
{
    int result;
    PyThread_acquire_lock(lock, 1);
    result = (*acquisition_count)++;
    PyThread_release_lock(lock);
    return result;
}
static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
                                   PyThread_type_lock lock)
{
    int result;
    PyThread_acquire_lock(lock, 1);
    result = (*acquisition_count)--;
    PyThread_release_lock(lock);
    return result;
}
static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
{
    int first_time;
    struct __pyx_memoryview_obj *memview = memslice->memview;
    if (!memview || (PyObject *) memview == Py_None)
        return;
    if (__pyx_get_slice_count(memview) < 0)
        __pyx_fatalerror("Acquisition count is %d (line %d)",
                         __pyx_get_slice_count(memview), lineno);
    first_time = __pyx_add_acquisition_count(memview) == 0;
    if (first_time) {
        if (have_gil) {
            Py_INCREF((PyObject *) memview);
        } else {
            PyGILState_STATE _gilstate = PyGILState_Ensure();
            Py_INCREF((PyObject *) memview);
            PyGILState_Release(_gilstate);
        }
    }
}
static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
                                             int have_gil, int lineno) {
    int last_time;
    struct __pyx_memoryview_obj *memview = memslice->memview;
    if (!memview ) {
        return;
    } else if ((PyObject *) memview == Py_None) {
        memslice->memview = NULL;
        return;
    }
    if (__pyx_get_slice_count(memview) <= 0)
        __pyx_fatalerror("Acquisition count is %d (line %d)",
                         __pyx_get_slice_count(memview), lineno);
    last_time = __pyx_sub_acquisition_count(memview) == 1;
    memslice->data = NULL;
    if (last_time) {
        if (have_gil) {
            Py_CLEAR(memslice->memview);
        } else {
            PyGILState_STATE _gilstate = PyGILState_Ensure();
            Py_CLEAR(memslice->memview);
            PyGILState_Release(_gilstate);
        }
    } else {
        memslice->memview = NULL;
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(!iternext)) {
#else
    if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
#endif
        PyErr_Format(PyExc_TypeError,
            "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
        return NULL;
    }
    next = iternext(iterator);
    if (likely(next))
        return next;
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_VERSION_HEX >= 0x02070000
    if (unlikely(iternext == &_PyObject_NextNotImplemented))
        return NULL;
#endif
#endif
    if (defval) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
            if (unlikely(exc_type != PyExc_StopIteration) &&
                    !PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
                return NULL;
            PyErr_Clear();
        }
        Py_INCREF(defval);
        return defval;
    }
    if (!PyErr_Occurred())
        PyErr_SetNone(PyExc_StopIteration);
    return NULL;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
    Py_ssize_t start = *_start, stop = *_stop, length = *_length;
    if (start < 0) {
        start += length;
        if (start < 0)
            start = 0;
    }
    if (stop < 0)
        stop += length;
    else if (stop > length)
        stop = length;
    *_length = stop - start;
    *_start = start;
    *_stop = stop;
}
static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
    PyObject *v;
    Py_ssize_t i;
    for (i = 0; i < length; i++) {
        v = dest[i] = src[i];
        Py_INCREF(v);
    }
}
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyList_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyList_New(0);
    dest = PyList_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyListObject*)src)->ob_item + start,
        ((PyListObject*)dest)->ob_item,
        length);
    return dest;
}
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyTuple_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyTuple_New(0);
    dest = PyTuple_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyTupleObject*)src)->ob_item + start,
        ((PyTupleObject*)dest)->ob_item,
        length);
    return dest;
}
#endif

static void __Pyx_RaiseBufferFallbackError(void) {
  PyErr_SetString(PyExc_ValueError,
     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
}

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    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 {
        if (default_value == Py_None)
            default_value = NULL;
        value = PyObject_CallMethodObjArgs(
            d, __pyx_n_s_get, key, default_value, NULL);
    }
#endif
    return value;
}

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

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 void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
#if CYTHON_COMPILING_IN_PYPY
    float_value = PyNumber_Float(obj);  if (0) goto bad;
#else
    PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
    if (likely(nb) && likely(nb->nb_float)) {
        float_value = nb->nb_float(obj);
        if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
            PyErr_Format(PyExc_TypeError,
                "__float__ returned non-float (type %.200s)",
                Py_TYPE(float_value)->tp_name);
            Py_DECREF(float_value);
            goto bad;
        }
    } 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_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
}

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 (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *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;
    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 PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (PyErr_ExceptionMatches(PyExc_OverflowError))
                    PyErr_Clear();
                else
                    goto bad;
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_COMPILING_IN_CPYTHON
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_ass_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (PyErr_ExceptionMatches(PyExc_OverflowError))
                    PyErr_Clear();
                else
                    goto bad;
            }
        }
        return ms->sq_ass_slice(obj, cstart, cstop, value);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_ass_subscript))
#endif
    {
        int result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_COMPILING_IN_CPYTHON
        result = mp->mp_ass_subscript(obj, py_slice, value);
#else
        result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object does not support slice %.10s",
        Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion");
bad:
    return -1;
}

static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_values, d);
    else
        return PyDict_Values(d);
}

static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *function = PyMethod_GET_FUNCTION(method);
            result = __Pyx_PyObject_CallOneArg(function, self);
            Py_DECREF(method);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

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 = __Pyx_PyObject_CallMethod0(iterable, method_name);
        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, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED 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 int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) {
    PyObject *iter, *key = NULL, *value = NULL;
    int source_is_dict, result;
    Py_ssize_t orig_length, ppos = 0;
    iter = __Pyx_dict_iterator(source_mapping, 0, __pyx_n_s_items, &orig_length, &source_is_dict);
    if (unlikely(!iter)) {
        PyObject *args;
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        args = PyTuple_Pack(1, source_mapping);
        if (likely(args)) {
            PyObject *fallback = PyObject_Call((PyObject*)&PyDict_Type, args, NULL);
            Py_DECREF(args);
            if (likely(fallback)) {
                iter = __Pyx_dict_iterator(fallback, 1, __pyx_n_s_items, &orig_length, &source_is_dict);
                Py_DECREF(fallback);
            }
        }
        if (unlikely(!iter)) goto bad;
    }
    while (1) {
        result = __Pyx_dict_iter_next(iter, orig_length, &ppos, &key, &value, NULL, source_is_dict);
        if (unlikely(result < 0)) goto bad;
        if (!result) break;
        if (unlikely(PyDict_Contains(kwdict, key))) {
            __Pyx_RaiseDoubleKeywordsError("function", key);
            result = -1;
        } else {
            result = PyDict_SetItem(kwdict, key, value);
        }
        Py_DECREF(key);
        Py_DECREF(value);
        if (unlikely(result < 0)) goto bad;
    }
    Py_XDECREF(iter);
    return 0;
bad:
    Py_XDECREF(iter);
    return -1;
}

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 PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_COMPILING_IN_CPYTHON
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    Py_ssize_t length;
    if (unlikely((start < 0) | (stop < 0))) {
        size_t slen = strlen(cstring);
        if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
            PyErr_SetString(PyExc_OverflowError,
                            "c-string too long to convert to Python");
            return NULL;
        }
        length = (Py_ssize_t) slen;
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    length = stop - start;
    if (unlikely(length <= 0))
        return PyUnicode_FromUnicode(NULL, 0);
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

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_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    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_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                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);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            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
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

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 int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result)
        result = __Pyx_GetModuleGlobalName(name);
    return result;
}

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 - start) / 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, (size_t)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,
        0,
        0,
        0,
        0,
        __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,
        __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;
    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_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*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);
}

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
    if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_ptype_7cpython_5array_array)) return __pyx_pw_7cpython_5array_5array_1__getbuffer__(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
        if (PyObject_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
    PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
    return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
    PyObject *obj = view->obj;
    if (!obj) return;
    if (PyObject_CheckBuffer(obj)) {
        PyBuffer_Release(view);
        return;
    }
        if (PyObject_TypeCheck(obj, __pyx_ptype_7cpython_5array_array)) { __pyx_pw_7cpython_5array_5array_3__releasebuffer__(obj, view); return; }
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; }
    Py_DECREF(obj);
    view->obj = NULL;
}
#endif


              #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            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 (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            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 (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_Strand(enum __pyx_t_7plastid_8genomics_8c_common_Strand value) {
    const enum __pyx_t_7plastid_8genomics_8c_common_Strand neg_one = (enum __pyx_t_7plastid_8genomics_8c_common_Strand) -1, const_zero = (enum __pyx_t_7plastid_8genomics_8c_common_Strand) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE enum __pyx_t_7plastid_8genomics_8c_common_Strand __Pyx_PyInt_As_enum____pyx_t_7plastid_8genomics_8c_common_Strand(PyObject *x) {
    const enum __pyx_t_7plastid_8genomics_8c_common_Strand neg_one = (enum __pyx_t_7plastid_8genomics_8c_common_Strand) -1, const_zero = (enum __pyx_t_7plastid_8genomics_8c_common_Strand) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) 0;
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, digit, digits[0])
                case 2:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) >= 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) (((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) >= 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) (((((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) >= 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) (((((((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7plastid_8genomics_8c_common_Strand, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7plastid_8genomics_8c_common_Strand, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) 0;
                case -1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) (((enum __pyx_t_7plastid_8genomics_8c_common_Strand)-1)*(((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 2 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) ((((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) (((enum __pyx_t_7plastid_8genomics_8c_common_Strand)-1)*(((((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 3 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) ((((((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) (((enum __pyx_t_7plastid_8genomics_8c_common_Strand)-1)*(((((((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(enum __pyx_t_7plastid_8genomics_8c_common_Strand, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) - 1 > 4 * PyLong_SHIFT) {
                            return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) ((((((((((enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[3]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[2]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[1]) << PyLong_SHIFT) | (enum __pyx_t_7plastid_8genomics_8c_common_Strand)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7plastid_8genomics_8c_common_Strand, long, PyLong_AsLong(x))
            } else if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_Strand) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(enum __pyx_t_7plastid_8genomics_8c_common_Strand, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            enum __pyx_t_7plastid_8genomics_8c_common_Strand val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            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 (enum __pyx_t_7plastid_8genomics_8c_common_Strand) -1;
        }
    } else {
        enum __pyx_t_7plastid_8genomics_8c_common_Strand val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) -1;
        val = __Pyx_PyInt_As_enum____pyx_t_7plastid_8genomics_8c_common_Strand(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to enum __pyx_t_7plastid_8genomics_8c_common_Strand");
    return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to enum __pyx_t_7plastid_8genomics_8c_common_Strand");
    return (enum __pyx_t_7plastid_8genomics_8c_common_Strand) -1;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_7plastid_8genomics_8c_common_ExBool(enum __pyx_t_7plastid_8genomics_8c_common_ExBool value) {
    const enum __pyx_t_7plastid_8genomics_8c_common_ExBool neg_one = (enum __pyx_t_7plastid_8genomics_8c_common_ExBool) -1, const_zero = (enum __pyx_t_7plastid_8genomics_8c_common_ExBool) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_ExBool) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_ExBool) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_ExBool) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_ExBool) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_7plastid_8genomics_8c_common_ExBool) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_7plastid_8genomics_8c_common_ExBool),
                                     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 PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) {
    const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum NPY_TYPES) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(enum NPY_TYPES) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES),
                                     little, !is_unsigned);
    }
}

static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice *mvs,
                             char order, int ndim)
{
    int i, index, step, start;
    Py_ssize_t itemsize = mvs->memview->view.itemsize;
    if (order == 'F') {
        step = 1;
        start = 0;
    } else {
        step = -1;
        start = ndim - 1;
    }
    for (i = 0; i < ndim; i++) {
        index = start + step * i;
        if (mvs->suboffsets[index] >= 0 || mvs->strides[index] != itemsize)
            return 0;
        itemsize *= mvs->shape[index];
    }
    return 1;
}

static void
__pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
                               void **out_start, void **out_end,
                               int ndim, size_t itemsize)
{
    char *start, *end;
    int i;
    start = end = slice->data;
    for (i = 0; i < ndim; i++) {
        Py_ssize_t stride = slice->strides[i];
        Py_ssize_t extent = slice->shape[i];
        if (extent == 0) {
            *out_start = *out_end = start;
            return;
        } else {
            if (stride > 0)
                end += stride * (extent - 1);
            else
                start += stride * (extent - 1);
        }
    }
    *out_start = start;
    *out_end = end + itemsize;
}
static int
__pyx_slices_overlap(__Pyx_memviewslice *slice1,
                     __Pyx_memviewslice *slice2,
                     int ndim, size_t itemsize)
{
    void *start1, *end1, *start2, *end2;
    __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
    __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
    return (start1 < end2) && (start2 < end1);
}

static __Pyx_memviewslice
__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
                                 const char *mode, int ndim,
                                 size_t sizeof_dtype, int contig_flag,
                                 int dtype_is_object)
{
    __Pyx_RefNannyDeclarations
    int i;
    __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
    struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
    Py_buffer *buf = &from_memview->view;
    PyObject *shape_tuple = NULL;
    PyObject *temp_int = NULL;
    struct __pyx_array_obj *array_obj = NULL;
    struct __pyx_memoryview_obj *memview_obj = NULL;
    __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
    for (i = 0; i < ndim; i++) {
        if (from_mvs->suboffsets[i] >= 0) {
            PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
                                           "indirect dimensions (axis %d)", i);
            goto fail;
        }
    }
    shape_tuple = PyTuple_New(ndim);
    if (unlikely(!shape_tuple)) {
        goto fail;
    }
    __Pyx_GOTREF(shape_tuple);
    for(i = 0; i < ndim; i++) {
        temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
        if(unlikely(!temp_int)) {
            goto fail;
        } else {
            PyTuple_SET_ITEM(shape_tuple, i, temp_int);
            temp_int = NULL;
        }
    }
    array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
    if (unlikely(!array_obj)) {
        goto fail;
    }
    __Pyx_GOTREF(array_obj);
    memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
                                    (PyObject *) array_obj, contig_flag,
                                    dtype_is_object,
                                    from_mvs->memview->typeinfo);
    if (unlikely(!memview_obj))
        goto fail;
    if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
        goto fail;
    if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
                                                dtype_is_object) < 0))
        goto fail;
    goto no_fail;
fail:
    __Pyx_XDECREF(new_mvs.memview);
    new_mvs.memview = NULL;
    new_mvs.data = NULL;
no_fail:
    __Pyx_XDECREF(shape_tuple);
    __Pyx_XDECREF(temp_int);
    __Pyx_XDECREF(array_obj);
    __Pyx_RefNannyFinishContext();
    return new_mvs;
}

static CYTHON_INLINE PyObject *
__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
{
    PyObject *cobj;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(p, sig, NULL);
#else
    cobj = PyCObject_FromVoidPtr(p, NULL);
#endif
    return cobj;
}

static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
    const char neg_one = (char) -1, const_zero = (char) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(char) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (char) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (char) 0;
                case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
                case 2:
                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
                            return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
                            return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
                            return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (char) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(char) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (char) 0;
                case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                            return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                            return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
                            return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(char) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
            } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            char val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            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 (char) -1;
        }
    } else {
        char val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (char) -1;
        val = __Pyx_PyInt_As_char(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to char");
    return (char) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to char");
    return (char) -1;
}

static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
{
    int i;
    if (!a || !b)
        return 0;
    if (a == b)
        return 1;
    if (a->size != b->size || a->typegroup != b->typegroup ||
            a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
        if (a->typegroup == 'H' || b->typegroup == 'H') {
            return a->size == b->size;
        } else {
            return 0;
        }
    }
    if (a->ndim) {
        for (i = 0; i < a->ndim; i++)
            if (a->arraysize[i] != b->arraysize[i])
                return 0;
    }
    if (a->typegroup == 'S') {
        if (a->flags != b->flags)
            return 0;
        if (a->fields || b->fields) {
            if (!(a->fields && b->fields))
                return 0;
            for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
                __Pyx_StructField *field_a = a->fields + i;
                __Pyx_StructField *field_b = b->fields + i;
                if (field_a->offset != field_b->offset ||
                    !__pyx_typeinfo_cmp(field_a->type, field_b->type))
                    return 0;
            }
            return !a->fields[i].type && !b->fields[i].type;
        }
    }
    return 1;
}

static int
__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
{
    if (buf->shape[dim] <= 1)
        return 1;
    if (buf->strides) {
        if (spec & __Pyx_MEMVIEW_CONTIG) {
            if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
                if (buf->strides[dim] != sizeof(void *)) {
                    PyErr_Format(PyExc_ValueError,
                                 "Buffer is not indirectly contiguous "
                                 "in dimension %d.", dim);
                    goto fail;
                }
            } else if (buf->strides[dim] != buf->itemsize) {
                PyErr_SetString(PyExc_ValueError,
                                "Buffer and memoryview are not contiguous "
                                "in the same dimension.");
                goto fail;
            }
        }
        if (spec & __Pyx_MEMVIEW_FOLLOW) {
            Py_ssize_t stride = buf->strides[dim];
            if (stride < 0)
                stride = -stride;
            if (stride < buf->itemsize) {
                PyErr_SetString(PyExc_ValueError,
                                "Buffer and memoryview are not contiguous "
                                "in the same dimension.");
                goto fail;
            }
        }
    } else {
        if (spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1) {
            PyErr_Format(PyExc_ValueError,
                         "C-contiguous buffer is not contiguous in "
                         "dimension %d", dim);
            goto fail;
        } else if (spec & (__Pyx_MEMVIEW_PTR)) {
            PyErr_Format(PyExc_ValueError,
                         "C-contiguous buffer is not indirect in "
                         "dimension %d", dim);
            goto fail;
        } else if (buf->suboffsets) {
            PyErr_SetString(PyExc_ValueError,
                            "Buffer exposes suboffsets but no strides");
            goto fail;
        }
    }
    return 1;
fail:
    return 0;
}
static int
__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
{
    if (spec & __Pyx_MEMVIEW_DIRECT) {
        if (buf->suboffsets && buf->suboffsets[dim] >= 0) {
            PyErr_Format(PyExc_ValueError,
                         "Buffer not compatible with direct access "
                         "in dimension %d.", dim);
            goto fail;
        }
    }
    if (spec & __Pyx_MEMVIEW_PTR) {
        if (!buf->suboffsets || (buf->suboffsets && buf->suboffsets[dim] < 0)) {
            PyErr_Format(PyExc_ValueError,
                         "Buffer is not indirectly accessible "
                         "in dimension %d.", dim);
            goto fail;
        }
    }
    return 1;
fail:
    return 0;
}
static int
__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
{
    int i;
    if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
        Py_ssize_t stride = 1;
        for (i = 0; i < ndim; i++) {
            if (stride * buf->itemsize != buf->strides[i] &&
                    buf->shape[i] > 1)
            {
                PyErr_SetString(PyExc_ValueError,
                    "Buffer not fortran contiguous.");
                goto fail;
            }
            stride = stride * buf->shape[i];
        }
    } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
        Py_ssize_t stride = 1;
        for (i = ndim - 1; i >- 1; i--) {
            if (stride * buf->itemsize != buf->strides[i] &&
                    buf->shape[i] > 1) {
                PyErr_SetString(PyExc_ValueError,
                    "Buffer not C contiguous.");
                goto fail;
            }
            stride = stride * buf->shape[i];
        }
    }
    return 1;
fail:
    return 0;
}
static int __Pyx_ValidateAndInit_memviewslice(
                int *axes_specs,
                int c_or_f_flag,
                int buf_flags,
                int ndim,
                __Pyx_TypeInfo *dtype,
                __Pyx_BufFmt_StackElem stack[],
                __Pyx_memviewslice *memviewslice,
                PyObject *original_obj)
{
    struct __pyx_memoryview_obj *memview, *new_memview;
    __Pyx_RefNannyDeclarations
    Py_buffer *buf;
    int i, spec = 0, retval = -1;
    __Pyx_BufFmt_Context ctx;
    int from_memoryview = __pyx_memoryview_check(original_obj);
    __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
    if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
                                                            original_obj)->typeinfo)) {
        memview = (struct __pyx_memoryview_obj *) original_obj;
        new_memview = NULL;
    } else {
        memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
                                            original_obj, buf_flags, 0, dtype);
        new_memview = memview;
        if (unlikely(!memview))
            goto fail;
    }
    buf = &memview->view;
    if (buf->ndim != ndim) {
        PyErr_Format(PyExc_ValueError,
                "Buffer has wrong number of dimensions (expected %d, got %d)",
                ndim, buf->ndim);
        goto fail;
    }
    if (new_memview) {
        __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 "u byte%s) "
                     "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
                     buf->itemsize,
                     (buf->itemsize > 1) ? "s" : "",
                     dtype->name,
                     dtype->size,
                     (dtype->size > 1) ? "s" : "");
        goto fail;
    }
    for (i = 0; i < ndim; i++) {
        spec = axes_specs[i];
        if (!__pyx_check_strides(buf, i, ndim, spec))
            goto fail;
        if (!__pyx_check_suboffsets(buf, i, ndim, spec))
            goto fail;
    }
    if (buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag))
        goto fail;
    if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
                                         new_memview != NULL) == -1)) {
        goto fail;
    }
    retval = 0;
    goto no_fail;
fail:
    Py_XDECREF(new_memview);
    retval = -1;
no_fail:
    __Pyx_RefNannyFinishContext();
    return retval;
}

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_long(PyObject *obj) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS, 1,
                                                 &__Pyx_TypeInfo_long, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_ds_int(PyObject *obj) {
    __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
    __Pyx_BufFmt_StackElem stack[1];
    int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
    int retcode;
    if (obj == Py_None) {
        result.memview = (struct __pyx_memoryview_obj *) Py_None;
        return result;
    }
    retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
                                                 PyBUF_RECORDS, 1,
                                                 &__Pyx_TypeInfo_int, stack,
                                                 &result, obj);
    if (unlikely(retcode == -1))
        goto __pyx_fail;
    return result;
__pyx_fail:
    result.memview = NULL;
    result.data = NULL;
    return result;
}

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *args;
            PyObject *function = PyMethod_GET_FUNCTION(method);
            args = PyTuple_New(2);
            if (unlikely(!args)) goto bad;
            Py_INCREF(self);
            PyTuple_SET_ITEM(args, 0, self);
            Py_INCREF(arg);
            PyTuple_SET_ITEM(args, 1, arg);
            Py_INCREF(function);
            Py_DECREF(method); method = NULL;
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
bad:
    Py_XDECREF(method);
    return result;
}

#include <structmember.h>
#include <frameobject.h>
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#define __Pyx_Coroutine_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 (likely(et == PyExc_StopIteration)) {
#if PY_VERSION_HEX >= 0x030300A0
        if (ev && Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
#endif
        if (!ev || !PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            if (!ev) {
                Py_INCREF(Py_None);
                ev = Py_None;
            } else if (PyTuple_Check(ev)) {
                if (PyTuple_GET_SIZE(ev) >= 1) {
                    PyObject *value;
#if CYTHON_COMPILING_IN_CPYTHON
                    value = PySequence_ITEM(ev, 0);
#else
                    value = PyTuple_GET_ITEM(ev, 0);
                    Py_INCREF(value);
#endif
                    Py_DECREF(ev);
                    ev = value;
                } else {
                    Py_INCREF(Py_None);
                    Py_DECREF(ev);
                    ev = Py_None;
                }
            }
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = ev;
            return 0;
        }
    } else if (!PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)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 = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_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_Coroutine_ExceptionClear(__pyx_CoroutineObject *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_Coroutine_CheckRunning(__pyx_CoroutineObject *gen) {
    if (unlikely(gen->is_running)) {
        PyErr_SetString(PyExc_ValueError,
                        "generator already executing");
        return 1;
    }
    return 0;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *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
        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_Coroutine_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
        if (self->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_CLEAR(f->f_back);
        }
#endif
    } else {
        __Pyx_Coroutine_ExceptionClear(self);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(PyObject *retval) {
    if (unlikely(!retval && !PyErr_Occurred())) {
        PyErr_SetNone(PyExc_StopIteration);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen_FetchStopIterationValue(&val);
    ret = __Pyx_Coroutine_SendEx(gen, val);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = PyIter_Next(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value);
    }
    return __Pyx_Coroutine_MethodReturn(retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_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_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Coroutine_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_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(__Pyx_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_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
        || raised_exception == PyExc_GeneratorExit
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
    {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) 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_Coroutine_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
            goto throw_here;
        }
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Throw(yf, args);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Throw(yf, args);
        } else
        #endif
        {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_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_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(__Pyx_Coroutine_SendEx(gen, NULL));
}
static int __Pyx_Coroutine_traverse(PyObject *self, visitproc visit, void *arg) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) 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_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) 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);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label > 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *res;
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    if (gen->resume_label <= 0)
        return ;
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
    res = __Pyx_Coroutine_Close(self);
    if (res == NULL)
        PyErr_WriteUnraisable(self);
    else
        Py_DECREF(res);
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        self->ob_refcnt = refcnt;
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
{
    Py_INCREF(self->gi_name);
    return self->gi_name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
{
    Py_INCREF(self->gi_qualname);
    return self->gi_qualname;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(PyTypeObject* type, __pyx_coroutine_body_t body,
                                                   PyObject *closure, PyObject *name, PyObject *qualname) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, 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;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    PyObject_GC_Track(gen);
    return gen;
}

static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
static PyObject* __Pyx_patch_abc_module(PyObject *module);
static PyObject* __Pyx_patch_abc_module(PyObject *module) {
    module = __Pyx_Coroutine_patch_module(
        module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
    );
    return module;
}
#endif
static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (!abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_VERSION_HEX >= 0x03030000) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_patch_abc_module(module);
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
        module = PyImport_ImportModule("backports_abc");
        if (module) {
            module = __Pyx_patch_abc_module(module);
            Py_XDECREF(module);
        }
        if (!module) {
            PyErr_Clear();
        }
    }
#else
    if (0) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
    0,
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    (iternextfunc) __Pyx_Generator_Next,
    __pyx_Generator_methods,
    __pyx_Generator_memberlist,
    __pyx_Generator_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if PY_VERSION_HEX >= 0x030400a1
    __Pyx_Coroutine_del,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    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);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
    PyObject *d;
    PyObject *cobj = 0;
    d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi);
    Py_XINCREF(d);
    if (!d) {
        d = PyDict_New();
        if (!d)
            goto bad;
        if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0)
            goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItem(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

#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_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    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,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s 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_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
        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;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else
        return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
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_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return __Pyx_NewRef(x);
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  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_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (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;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(x);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  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) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
