/* Generated by Cython 0.25.2 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/htslib_util.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/bgzf.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/cram.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/faidx.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/hfile.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/hts.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/kstring.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/sam.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/tbx.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/vcf.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib/htslib/vcfutils.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/pysam_stream.h",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/samfile_util.h"
        ],
        "include_dirs": [
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/htslib",
            "/home/aliman/pyenv/dev-pysamstats-py36/lib/python3.6/site-packages/pysam/include/samtools"
        ]
    },
    "module_name": "pysamstats.opt"
}
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_25_2"
#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 HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
    #define HAVE_LONG_LONG
  #endif
#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_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
#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
#ifndef METH_FASTCALL
  #define METH_FASTCALL 0x80
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
                                              Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 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_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #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)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #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_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #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]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#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
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#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 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#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)
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
#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 CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    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))
  #endif
#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
#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_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif 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 defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif


#define __PYX_ERR(f_index, lineno, Ln_error) \
{ \
  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
}

#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_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(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__pysamstats__opt
#define __PYX_HAVE_API__pysamstats__opt
#include <stdint.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include "pythread.h"
#include <stdlib.h>
#include <sys/types.h>
#include "stdarg.h"
#include "htslib/kstring.h"
#include "htslib_util.h"
#include "htslib/hfile.h"
#include "htslib/bgzf.h"
#include "htslib/hts.h"
#include "htslib/sam.h"
#include "htslib/faidx.h"
#include "htslib/tbx.h"
#include "htslib/vcf.h"
#include "htslib/vcfutils.h"
#include "htslib/cram.h"
#include "pysam_stream.h"
#include "samfile_util.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const 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 (_MSC_VER) && defined (_M_X64)
    #define __Pyx_sst_abs(value) _abs64(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(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_IntOrLong(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_ASSUME_SAFE_MACROS
#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
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(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 PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "pysamstats/opt.pyx",
  "array.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
  "libchtslib.pxd",
  "libcfaidx.pxd",
  "libcalignedsegment.pxd",
  "libcalignmentfile.pxd",
};

/*--- Type declarations ---*/
#ifndef _ARRAYARRAY_H
struct arrayobject;
typedef struct arrayobject arrayobject;
#endif
struct __pyx_obj_5pysam_10libchtslib_HTSFile;
struct __pyx_obj_5pysam_9libcfaidx_FastaFile;
struct __pyx_obj_5pysam_9libcfaidx_FastqProxy;
struct __pyx_obj_5pysam_9libcfaidx_PersistentFastqProxy;
struct __pyx_obj_5pysam_9libcfaidx_FastxFile;
struct __pyx_obj_5pysam_9libcfaidx_FastqFile;
struct __pyx_obj_5pysam_9libcfaidx_Fastafile;
struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment;
struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn;
struct __pyx_obj_5pysam_18libcalignedsegment_PileupRead;
struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile;
struct __pyx_obj_5pysam_17libcalignmentfile_PileupColumn;
struct __pyx_obj_5pysam_17libcalignmentfile_PileupRead;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRow;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowHead;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowAll;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowAllRefs;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowSelection;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumnRegion;
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumnAllRefs;
struct __pyx_obj_5pysam_17libcalignmentfile_IndexedReads;
struct __pyx_obj_10pysamstats_3opt_PileupStat;
struct __pyx_obj_10pysamstats_3opt_CountPp;
struct __pyx_obj_10pysamstats_3opt_Coverage;
struct __pyx_obj_10pysamstats_3opt_CountPpStrand;
struct __pyx_obj_10pysamstats_3opt_CoverageStrand;
struct __pyx_obj_10pysamstats_3opt_CoverageExt;
struct __pyx_obj_10pysamstats_3opt_CountStrand;
struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand;
struct __pyx_obj_10pysamstats_3opt_Variation;
struct __pyx_obj_10pysamstats_3opt_VariationStrand;
struct __pyx_obj_10pysamstats_3opt_TlenHelper;
struct __pyx_obj_10pysamstats_3opt_Tlen;
struct __pyx_obj_10pysamstats_3opt_TlenStrand;
struct __pyx_obj_10pysamstats_3opt_MapqHelper;
struct __pyx_obj_10pysamstats_3opt_Mapq;
struct __pyx_obj_10pysamstats_3opt_MapqStrand;
struct __pyx_obj_10pysamstats_3opt_BaseqHelper;
struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper;
struct __pyx_obj_10pysamstats_3opt_Baseq;
struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper;
struct __pyx_obj_10pysamstats_3opt_BaseqStrand;
struct __pyx_obj_10pysamstats_3opt_BaseqExt;
struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand;
struct __pyx_obj_10pysamstats_3opt_CoverageGC;
struct __pyx_obj_10pysamstats_3opt_BinnedStat;
struct __pyx_obj_10pysamstats_3opt_CoverageBinned;
struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned;
struct __pyx_obj_10pysamstats_3opt_MapqBinned;
struct __pyx_obj_10pysamstats_3opt_AlignmentBinned;
struct __pyx_obj_10pysamstats_3opt_TlenBinned;
struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default;
struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom;
struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom;
struct __pyx_opt_args_5pysam_9libcfaidx_10FastqProxy_get_quality_array;
struct __pyx_opt_args_5pysam_9libcfaidx_20PersistentFastqProxy_get_quality_array;

/* "pysam/libcfaidx.pxd":48
 *     cdef kseq_t * _delegate
 *     cdef cython.str tostring(self)
 *     cpdef array.array get_quality_array(self, int offset=*)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_opt_args_5pysam_9libcfaidx_10FastqProxy_get_quality_array {
  int __pyx_n;
  int offset;
};

/* "pysam/libcfaidx.pxd":57
 *     cdef public str comment, quality, sequence, name
 *     cdef cython.str tostring(self)
 *     cpdef array.array get_quality_array(self, int offset=*)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_opt_args_5pysam_9libcfaidx_20PersistentFastqProxy_get_quality_array {
  int __pyx_n;
  int offset;
};
struct __pyx_opt_args_5pysam_18libcalignedsegment_14AlignedSegment_set_tag;
struct __pyx_opt_args_5pysam_18libcalignedsegment_14AlignedSegment_get_tag;

/* "pysam/libcalignedsegment.pxd":30
 * 
 * from pysam.libcalignmentfile cimport AlignmentFile
 * ctypedef AlignmentFile AlignmentFile_t             # <<<<<<<<<<<<<<
 * 
 * 
 */
typedef struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_t_5pysam_18libcalignedsegment_AlignmentFile_t;

/* "pysam/libcalignedsegment.pxd":50
 *     # add an alignment tag with value to the AlignedSegment
 *     # an existing tag of the same name will be replaced.
 *     cpdef set_tag(self, tag, value, value_type=?, replace=?)             # <<<<<<<<<<<<<<
 * 
 *     # add an alignment tag with value to the AlignedSegment
 */
struct __pyx_opt_args_5pysam_18libcalignedsegment_14AlignedSegment_set_tag {
  int __pyx_n;
  PyObject *value_type;
  PyObject *replace;
};

/* "pysam/libcalignedsegment.pxd":54
 *     # add an alignment tag with value to the AlignedSegment
 *     # an existing tag of the same name will be replaced.
 *     cpdef get_tag(self, tag, with_value_type=?)             # <<<<<<<<<<<<<<
 * 
 *     # return true if tag exists
 */
struct __pyx_opt_args_5pysam_18libcalignedsegment_14AlignedSegment_get_tag {
  int __pyx_n;
  PyObject *with_value_type;
};
struct __pyx_t_5pysam_17libcalignmentfile___iterdata;
typedef struct __pyx_t_5pysam_17libcalignmentfile___iterdata __pyx_t_5pysam_17libcalignmentfile___iterdata;
struct __pyx_opt_args_5pysam_17libcalignmentfile_14IteratorColumn_setupIteratorData;

/* "pysam/libcalignmentfile.pxd":29
 * # Utility types
 * 
 * ctypedef struct __iterdata:             # <<<<<<<<<<<<<<
 *     htsFile * htsfile
 *     bam_hdr_t * header
 */
struct __pyx_t_5pysam_17libcalignmentfile___iterdata {
  htsFile *htsfile;
  bam_hdr_t *header;
  hts_itr_t *iter;
  faidx_t *fastafile;
  int tid;
  char *seq;
  int seq_len;
};

/* "pysam/libcalignmentfile.pxd":131
 *     cdef char * getSequence(self)
 *     cdef setMask(self, mask)
 *     cdef setupIteratorData(self,             # <<<<<<<<<<<<<<
 *                            int tid,
 *                            int start,
 */
struct __pyx_opt_args_5pysam_17libcalignmentfile_14IteratorColumn_setupIteratorData {
  int __pyx_n;
  int multiple_iterators;
};

/* "pysam/libchtslib.pxd":2563
 * 
 * 
 * cdef class HTSFile(object):             # <<<<<<<<<<<<<<
 *     cdef          htsFile *htsfile       # pointer to htsFile structure
 *     cdef          int64_t start_offset   # BGZF offset of first record
 */
struct __pyx_obj_5pysam_10libchtslib_HTSFile {
  PyObject_HEAD
  struct __pyx_vtabstruct_5pysam_10libchtslib_HTSFile *__pyx_vtab;
  htsFile *htsfile;
  int64_t start_offset;
  PyObject *filename;
  PyObject *mode;
  PyObject *index_filename;
  int is_stream;
  int is_remote;
  int duplicate_filehandle;
};


/* "pysam/libcfaidx.pxd":37
 *                     int * dret)
 * 
 * cdef class FastaFile:             # <<<<<<<<<<<<<<
 *     cdef bint is_remote
 *     cdef object _filename, _references, _lengths, reference2length
 */
struct __pyx_obj_5pysam_9libcfaidx_FastaFile {
  PyObject_HEAD
  struct __pyx_vtabstruct_5pysam_9libcfaidx_FastaFile *__pyx_vtab;
  int is_remote;
  PyObject *_filename;
  PyObject *_references;
  PyObject *_lengths;
  PyObject *reference2length;
  faidx_t *fastafile;
};


/* "pysam/libcfaidx.pxd":45
 * 
 * 
 * cdef class FastqProxy:             # <<<<<<<<<<<<<<
 *     cdef kseq_t * _delegate
 *     cdef cython.str tostring(self)
 */
struct __pyx_obj_5pysam_9libcfaidx_FastqProxy {
  PyObject_HEAD
  struct __pyx_vtabstruct_5pysam_9libcfaidx_FastqProxy *__pyx_vtab;
  kseq_t *_delegate;
};


/* "pysam/libcfaidx.pxd":51
 * 
 * 
 * cdef class PersistentFastqProxy:             # <<<<<<<<<<<<<<
 *     """
 *     Python container for pysam.libcfaidx.FastqProxy with persistence.
 */
struct __pyx_obj_5pysam_9libcfaidx_PersistentFastqProxy {
  PyObject_HEAD
  struct __pyx_vtabstruct_5pysam_9libcfaidx_PersistentFastqProxy *__pyx_vtab;
  PyObject *comment;
  PyObject *quality;
  PyObject *sequence;
  PyObject *name;
};


/* "pysam/libcfaidx.pxd":60
 * 
 * 
 * cdef class FastxFile:             # <<<<<<<<<<<<<<
 *     cdef object _filename
 *     cdef BGZF * fastqfile
 */
struct __pyx_obj_5pysam_9libcfaidx_FastxFile {
  PyObject_HEAD
  struct __pyx_vtabstruct_5pysam_9libcfaidx_FastxFile *__pyx_vtab;
  PyObject *_filename;
  BGZF *fastqfile;
  kseq_t *entry;
  int persist;
  int is_remote;
};


/* "pysam/libcfaidx.pxd":72
 * 
 * # Compatibility Layer for pysam 0.8.1
 * cdef class FastqFile(FastxFile):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_5pysam_9libcfaidx_FastqFile {
  struct __pyx_obj_5pysam_9libcfaidx_FastxFile __pyx_base;
};


/* "pysam/libcfaidx.pxd":77
 * 
 * # Compatibility Layer for pysam < 0.8
 * cdef class Fastafile(FastaFile):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_5pysam_9libcfaidx_Fastafile {
  struct __pyx_obj_5pysam_9libcfaidx_FastaFile __pyx_base;
};


/* "pysam/libcalignedsegment.pxd":34
 * 
 * # Note: need to declare all C fields and methods here
 * cdef class AlignedSegment:             # <<<<<<<<<<<<<<
 * 
 *     # object that this AlignedSegment represents
 */
struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment {
  PyObject_HEAD
  struct __pyx_vtabstruct_5pysam_18libcalignedsegment_AlignedSegment *__pyx_vtab;
  bam1_t *_delegate;
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *_alignment_file;
  PyObject *cache_query_qualities;
  PyObject *cache_query_alignment_qualities;
  PyObject *cache_query_sequence;
  PyObject *cache_query_alignment_sequence;
};


/* "pysam/libcalignedsegment.pxd":63
 * 
 * 
 * cdef class PileupColumn:             # <<<<<<<<<<<<<<
 *     cdef bam_pileup1_t ** plp
 *     cdef int tid
 */
struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn {
  PyObject_HEAD
  bam_pileup1_t **plp;
  int tid;
  int pos;
  int n_pu;
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *_alignment_file;
};


/* "pysam/libcalignedsegment.pxd":71
 * 
 * 
 * cdef class PileupRead:             # <<<<<<<<<<<<<<
 *     cdef AlignedSegment _alignment
 *     cdef int32_t  _qpos
 */
struct __pyx_obj_5pysam_18libcalignedsegment_PileupRead {
  PyObject_HEAD
  struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment *_alignment;
  int32_t _qpos;
  int _indel;
  int _level;
  uint32_t _is_del;
  uint32_t _is_head;
  uint32_t _is_tail;
  uint32_t _is_refskip;
};


/* "pysam/libcalignmentfile.pxd":39
 * 
 * 
 * cdef class AlignmentFile(HTSFile):             # <<<<<<<<<<<<<<
 *     cdef readonly object reference_filename
 * 
 */
struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile {
  struct __pyx_obj_5pysam_10libchtslib_HTSFile __pyx_base;
  PyObject *reference_filename;
  hts_idx_t *index;
  bam_hdr_t *header;
  bam1_t *b;
};


/* "pysam/libcalignmentfile.pxd":57
 * 
 * 
 * cdef class PileupColumn:             # <<<<<<<<<<<<<<
 *     cdef bam_pileup1_t ** plp
 *     cdef int tid
 */
struct __pyx_obj_5pysam_17libcalignmentfile_PileupColumn {
  PyObject_HEAD
  bam_pileup1_t **plp;
  int tid;
  int pos;
  int n_pu;
};


/* "pysam/libcalignmentfile.pxd":64
 * 
 * 
 * cdef class PileupRead:             # <<<<<<<<<<<<<<
 *     cdef AlignedSegment _alignment
 *     cdef int32_t  _qpos
 */
struct __pyx_obj_5pysam_17libcalignmentfile_PileupRead {
  PyObject_HEAD
  struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment *_alignment;
  int32_t _qpos;
  int _indel;
  int _level;
  uint32_t _is_del;
  uint32_t _is_head;
  uint32_t _is_tail;
  uint32_t _is_refskip;
};


/* "pysam/libcalignmentfile.pxd":75
 * 
 * 
 * cdef class IteratorRow:             # <<<<<<<<<<<<<<
 *     cdef int retval
 *     cdef bam1_t * b
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRow {
  PyObject_HEAD
  int retval;
  bam1_t *b;
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *samfile;
  htsFile *htsfile;
  bam_hdr_t *header;
  int owns_samfile;
};


/* "pysam/libcalignmentfile.pxd":84
 * 
 * 
 * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef hts_itr_t * iter
 *     cdef bam1_t * getCurrent(self)
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion {
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRow __pyx_base;
  struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion *__pyx_vtab;
  hts_itr_t *iter;
};


/* "pysam/libcalignmentfile.pxd":89
 *     cdef int cnext(self)
 * 
 * cdef class IteratorRowHead(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef int max_rows
 *     cdef int current_row
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowHead {
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRow __pyx_base;
  struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowHead *__pyx_vtab;
  int max_rows;
  int current_row;
};


/* "pysam/libcalignmentfile.pxd":95
 *     cdef int cnext(self)
 * 
 * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef bam1_t * getCurrent(self)
 *     cdef int cnext(self)
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowAll {
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRow __pyx_base;
  struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowAll *__pyx_vtab;
};


/* "pysam/libcalignmentfile.pxd":100
 * 
 * 
 * cdef class IteratorRowAllRefs(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef int         tid
 *     cdef IteratorRowRegion rowiter
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowAllRefs {
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRow __pyx_base;
  int tid;
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *rowiter;
};


/* "pysam/libcalignmentfile.pxd":105
 * 
 * 
 * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef int current_pos
 *     cdef positions
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowSelection {
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRow __pyx_base;
  struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowSelection *__pyx_vtab;
  int current_pos;
  PyObject *positions;
};


/* "pysam/libcalignmentfile.pxd":112
 * 
 * 
 * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
 * 
 *     # result of the last plbuf_push
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn {
  PyObject_HEAD
  struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumn *__pyx_vtab;
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *iter;
  int tid;
  int pos;
  int n_plp;
  int mask;
  bam_pileup1_t *plp;
  bam_plp_t pileup_iter;
  __pyx_t_5pysam_17libcalignmentfile___iterdata iterdata;
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *samfile;
  struct __pyx_obj_5pysam_9libcfaidx_Fastafile *fastafile;
  PyObject *stepper;
  int max_depth;
};


/* "pysam/libcalignmentfile.pxd":141
 * 
 * 
 * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
 *     cdef int start
 *     cdef int end
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumnRegion {
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn __pyx_base;
  int start;
  int end;
  int truncate;
};


/* "pysam/libcalignmentfile.pxd":147
 * 
 * 
 * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumnAllRefs {
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn __pyx_base;
};


/* "pysam/libcalignmentfile.pxd":151
 * 
 * 
 * cdef class IndexedReads:             # <<<<<<<<<<<<<<
 *     cdef AlignmentFile samfile
 *     cdef htsFile * htsfile
 */
struct __pyx_obj_5pysam_17libcalignmentfile_IndexedReads {
  PyObject_HEAD
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *samfile;
  htsFile *htsfile;
  PyObject *index;
  int owns_samfile;
  bam_hdr_t *header;
};


/* "pysamstats/opt.pyx":74
 * 
 * 
 * cdef class PileupStat(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
struct __pyx_obj_10pysamstats_3opt_PileupStat {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat *__pyx_vtab;
};


/* "pysamstats/opt.pyx":89
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CountPp:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int all, pp
 */
struct __pyx_obj_10pysamstats_3opt_CountPp {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *__pyx_vtab;
  int all;
  int pp;
};


/* "pysamstats/opt.pyx":106
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Coverage(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_Coverage {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_CountPp *reads;
};


/* "pysamstats/opt.pyx":146
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CountPpStrand:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int all, pp, fwd, rev, pp_fwd, pp_rev
 */
struct __pyx_obj_10pysamstats_3opt_CountPpStrand {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *__pyx_vtab;
  int all;
  int pp;
  int fwd;
  int rev;
  int pp_fwd;
  int pp_rev;
};


/* "pysamstats/opt.pyx":171
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CoverageStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_CoverageStrand {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *reads;
};


/* "pysamstats/opt.pyx":219
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CoverageExt(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_CoverageExt {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  int reads_all;
  int reads_pp;
  int reads_mate_unmapped;
  int reads_mate_other_chr;
  int reads_mate_same_strand;
  int reads_faceaway;
  int reads_softclipped;
  int reads_duplicate;
};


/* "pysamstats/opt.pyx":304
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CountStrand:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int all, fwd, rev
 */
struct __pyx_obj_10pysamstats_3opt_CountStrand {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *__pyx_vtab;
  int all;
  int fwd;
  int rev;
};


/* "pysamstats/opt.pyx":323
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CoverageExtStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_CountStrand *all;
  struct __pyx_obj_10pysamstats_3opt_CountStrand *pp;
  struct __pyx_obj_10pysamstats_3opt_CountStrand *mate_unmapped;
  struct __pyx_obj_10pysamstats_3opt_CountStrand *mate_other_chr;
  struct __pyx_obj_10pysamstats_3opt_CountStrand *same_strand;
  struct __pyx_obj_10pysamstats_3opt_CountStrand *faceaway;
  struct __pyx_obj_10pysamstats_3opt_CountStrand *softclipped;
  struct __pyx_obj_10pysamstats_3opt_CountStrand *duplicate;
};


/* "pysamstats/opt.pyx":434
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Variation(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_Variation {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_CountPp *reads;
  struct __pyx_obj_10pysamstats_3opt_CountPp *matches;
  struct __pyx_obj_10pysamstats_3opt_CountPp *mismatches;
  struct __pyx_obj_10pysamstats_3opt_CountPp *deletions;
  struct __pyx_obj_10pysamstats_3opt_CountPp *insertions;
  struct __pyx_obj_10pysamstats_3opt_CountPp *A;
  struct __pyx_obj_10pysamstats_3opt_CountPp *C;
  struct __pyx_obj_10pysamstats_3opt_CountPp *T;
  struct __pyx_obj_10pysamstats_3opt_CountPp *G;
  struct __pyx_obj_10pysamstats_3opt_CountPp *N;
};


/* "pysamstats/opt.pyx":543
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class VariationStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_VariationStrand {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *reads;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *matches;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *mismatches;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *deletions;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *insertions;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *A;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *C;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *T;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *G;
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *N;
};


/* "pysamstats/opt.pyx":678
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class TlenHelper:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_TlenHelper {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *__pyx_vtab;
  long n;
  double m;
  double m2;
  double d;
  double d2;
  int64_t s;
  int64_t sq;
};


/* "pysamstats/opt.pyx":730
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Tlen(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_Tlen {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  int reads_all;
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *tlen;
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *tlen_pp;
};


/* "pysamstats/opt.pyx":795
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class TlenStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_TlenStrand {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  int reads_all;
  int reads_fwd;
  int reads_rev;
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *tlen;
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *tlen_fwd;
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *tlen_rev;
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *tlen_pp;
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *tlen_pp_fwd;
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *tlen_pp_rev;
};


/* "pysamstats/opt.pyx":911
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class MapqHelper:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int n
 */
struct __pyx_obj_10pysamstats_3opt_MapqHelper {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *__pyx_vtab;
  int n;
  int nz;
  uint64_t max;
  uint64_t sqsum;
};


/* "pysamstats/opt.pyx":940
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Mapq(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_Mapq {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *all;
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *pp;
};


/* "pysamstats/opt.pyx":996
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class MapqStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_MapqStrand {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *all;
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *fwd;
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *rev;
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *pp;
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *pp_fwd;
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *pp_rev;
};


/* "pysamstats/opt.pyx":1092
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqHelper:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_BaseqHelper {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *__pyx_vtab;
  int n;
  int n_nodel;
  uint64_t sqsum;
};


/* "pysamstats/opt.pyx":1118
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqPpHelper:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_BaseqPpHelper *__pyx_vtab;
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *all;
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *pp;
};


/* "pysamstats/opt.pyx":1140
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Baseq(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_Baseq {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *helper;
};


/* "pysamstats/opt.pyx":1187
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqStrandPpHelper:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrandPpHelper *__pyx_vtab;
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *all;
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *fwd;
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *rev;
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *pp;
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *pp_fwd;
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *pp_rev;
};


/* "pysamstats/opt.pyx":1229
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_BaseqStrand {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *helper;
};


/* "pysamstats/opt.pyx":1291
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqExt(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_BaseqExt {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *all;
  struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *matches;
  struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *mismatches;
};


/* "pysamstats/opt.pyx":1366
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqExtStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *all;
  struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *matches;
  struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *mismatches;
};


/* "pysamstats/opt.pyx":1470
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CoverageGC(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt_CoverageGC {
  struct __pyx_obj_10pysamstats_3opt_PileupStat __pyx_base;
  struct __pyx_obj_10pysamstats_3opt_CountPp *reads;
  int window_size;
  int window_offset;
};


/* "pysamstats/opt.pyx":1541
 * 
 * 
 * cdef class BinnedStat(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):
 */
struct __pyx_obj_10pysamstats_3opt_BinnedStat {
  PyObject_HEAD
  struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat *__pyx_vtab;
};


/* "pysamstats/opt.pyx":1550
 * 
 * 
 * cdef class CoverageBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all, reads_pp
 */
struct __pyx_obj_10pysamstats_3opt_CoverageBinned {
  struct __pyx_obj_10pysamstats_3opt_BinnedStat __pyx_base;
  int reads_all;
  int reads_pp;
};


/* "pysamstats/opt.pyx":1591
 * 
 * 
 * cdef class CoverageExtBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all, reads_pp, reads_mate_unmapped, reads_mate_other_chr, \
 */
struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned {
  struct __pyx_obj_10pysamstats_3opt_BinnedStat __pyx_base;
  int reads_all;
  int reads_pp;
  int reads_mate_unmapped;
  int reads_mate_other_chr;
  int reads_mate_same_strand;
  int reads_faceaway;
  int reads_softclipped;
  int reads_duplicate;
};


/* "pysamstats/opt.pyx":1669
 * 
 * 
 * cdef class MapqBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all, reads_mapq0
 */
struct __pyx_obj_10pysamstats_3opt_MapqBinned {
  struct __pyx_obj_10pysamstats_3opt_BinnedStat __pyx_base;
  int reads_all;
  int reads_mapq0;
  uint64_t mapq;
  uint64_t mapq_squared_sum;
};


/* "pysamstats/opt.pyx":1710
 * 
 * 
 * cdef class AlignmentBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all, M, I, D, N, S, H, P, EQ, X
 */
struct __pyx_obj_10pysamstats_3opt_AlignmentBinned {
  struct __pyx_obj_10pysamstats_3opt_BinnedStat __pyx_base;
  int reads_all;
  int M;
  int I;
  int D;
  int N;
  int S;
  int H;
  int P;
  int EQ;
  int X;
};


/* "pysamstats/opt.pyx":1771
 * 
 * 
 * cdef class TlenBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all
 */
struct __pyx_obj_10pysamstats_3opt_TlenBinned {
  struct __pyx_obj_10pysamstats_3opt_BinnedStat __pyx_base;
  int reads_all;
  int reads_pp;
  int64_t tlen_sum;
  int64_t tlen_pp_sum;
  int64_t tlen_squared_sum;
  int64_t tlen_pp_squared_sum;
};


/* "pysamstats/opt.pyx":1845
 * 
 * 
 * def iter_pileup_default(stat, alignmentfile, fafile, chrom, start, end, one_based, truncate,             # <<<<<<<<<<<<<<
 *                         max_depth, int min_mapq, int min_baseq, bint no_del, bint no_dup):
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default {
  PyObject_HEAD
  PyObject *__pyx_v_alignmentfile;
  PyObject *__pyx_v_chrom;
  struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col;
  PyObject *__pyx_v_end;
  PyObject *__pyx_v_fafile;
  PyObject *__pyx_v_it;
  PyObject *__pyx_v_max_depth;
  int __pyx_v_min_baseq;
  int __pyx_v_min_mapq;
  int __pyx_v_no_del;
  int __pyx_v_no_dup;
  PyObject *__pyx_v_one_based;
  PyObject *__pyx_v_rec;
  PyObject *__pyx_v_start;
  PyObject *__pyx_v_stat;
  PyObject *__pyx_v_truncate;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysamstats/opt.pyx":1935
 * 
 * 
 * def iter_pileup_padded_chrom(PileupStat stat, alignmentfile, fafile, chrom, start, end,             # <<<<<<<<<<<<<<
 *                              one_based, truncate, max_depth, min_mapq, min_baseq, no_del, no_dup):
 *     cdef:
 */
struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom {
  PyObject_HEAD
  PyObject *__pyx_v_alignmentfile;
  PyObject *__pyx_v_chrom;
  struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col;
  int __pyx_v_curpos;
  PyObject *__pyx_v_end;
  PyObject *__pyx_v_fafile;
  PyObject *__pyx_v_it;
  PyObject *__pyx_v_max_depth;
  PyObject *__pyx_v_min_baseq;
  PyObject *__pyx_v_min_mapq;
  PyObject *__pyx_v_no_del;
  PyObject *__pyx_v_no_dup;
  PyObject *__pyx_v_one_based;
  long __pyx_v_pos;
  PyObject *__pyx_v_rec;
  PyObject *__pyx_v_refbase;
  PyObject *__pyx_v_start;
  struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_stat;
  PyObject *__pyx_v_truncate;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "pysamstats/opt.pyx":2025
 * 
 * 
 * def iter_binned_chrom(BinnedStat stat, AlignmentFile alignmentfile, FastaFile fafile,             # <<<<<<<<<<<<<<
 *                       chrom, start, end, one_based, int window_size, int window_offset,
 *                       int min_mapq, int no_dup):
 */
struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom {
  PyObject_HEAD
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile;
  bam1_t *__pyx_v_b;
  int __pyx_v_bin_end;
  int __pyx_v_bin_start;
  PyObject *__pyx_v_chrom;
  PyObject *__pyx_v_end;
  struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile;
  int __pyx_v_has_coord;
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *__pyx_v_it;
  int __pyx_v_min_mapq;
  int __pyx_v_no_dup;
  PyObject *__pyx_v_one_based;
  PyObject *__pyx_v_pos;
  PyObject *__pyx_v_rec;
  int __pyx_v_rend;
  int __pyx_v_rstart;
  int __pyx_v_rtid;
  PyObject *__pyx_v_start;
  struct __pyx_obj_10pysamstats_3opt_BinnedStat *__pyx_v_stat;
  int __pyx_v_window_offset;
  int __pyx_v_window_size;
};



/* "pysam/libchtslib.pxd":2563
 * 
 * 
 * cdef class HTSFile(object):             # <<<<<<<<<<<<<<
 *     cdef          htsFile *htsfile       # pointer to htsFile structure
 *     cdef          int64_t start_offset   # BGZF offset of first record
 */

struct __pyx_vtabstruct_5pysam_10libchtslib_HTSFile {
  htsFile *(*_open_htsfile)(struct __pyx_obj_5pysam_10libchtslib_HTSFile *);
};
static struct __pyx_vtabstruct_5pysam_10libchtslib_HTSFile *__pyx_vtabptr_5pysam_10libchtslib_HTSFile;


/* "pysam/libcfaidx.pxd":37
 *                     int * dret)
 * 
 * cdef class FastaFile:             # <<<<<<<<<<<<<<
 *     cdef bint is_remote
 *     cdef object _filename, _references, _lengths, reference2length
 */

struct __pyx_vtabstruct_5pysam_9libcfaidx_FastaFile {
  char *(*_fetch)(struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, char *, int, int, int *);
};
static struct __pyx_vtabstruct_5pysam_9libcfaidx_FastaFile *__pyx_vtabptr_5pysam_9libcfaidx_FastaFile;


/* "pysam/libcfaidx.pxd":45
 * 
 * 
 * cdef class FastqProxy:             # <<<<<<<<<<<<<<
 *     cdef kseq_t * _delegate
 *     cdef cython.str tostring(self)
 */

struct __pyx_vtabstruct_5pysam_9libcfaidx_FastqProxy {
  PyObject *(*tostring)(struct __pyx_obj_5pysam_9libcfaidx_FastqProxy *);
  arrayobject *(*get_quality_array)(struct __pyx_obj_5pysam_9libcfaidx_FastqProxy *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcfaidx_10FastqProxy_get_quality_array *__pyx_optional_args);
};
static struct __pyx_vtabstruct_5pysam_9libcfaidx_FastqProxy *__pyx_vtabptr_5pysam_9libcfaidx_FastqProxy;


/* "pysam/libcfaidx.pxd":51
 * 
 * 
 * cdef class PersistentFastqProxy:             # <<<<<<<<<<<<<<
 *     """
 *     Python container for pysam.libcfaidx.FastqProxy with persistence.
 */

struct __pyx_vtabstruct_5pysam_9libcfaidx_PersistentFastqProxy {
  PyObject *(*tostring)(struct __pyx_obj_5pysam_9libcfaidx_PersistentFastqProxy *);
  arrayobject *(*get_quality_array)(struct __pyx_obj_5pysam_9libcfaidx_PersistentFastqProxy *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_9libcfaidx_20PersistentFastqProxy_get_quality_array *__pyx_optional_args);
};
static struct __pyx_vtabstruct_5pysam_9libcfaidx_PersistentFastqProxy *__pyx_vtabptr_5pysam_9libcfaidx_PersistentFastqProxy;


/* "pysam/libcfaidx.pxd":60
 * 
 * 
 * cdef class FastxFile:             # <<<<<<<<<<<<<<
 *     cdef object _filename
 *     cdef BGZF * fastqfile
 */

struct __pyx_vtabstruct_5pysam_9libcfaidx_FastxFile {
  kseq_t *(*getCurrent)(struct __pyx_obj_5pysam_9libcfaidx_FastxFile *);
  int (*cnext)(struct __pyx_obj_5pysam_9libcfaidx_FastxFile *);
};
static struct __pyx_vtabstruct_5pysam_9libcfaidx_FastxFile *__pyx_vtabptr_5pysam_9libcfaidx_FastxFile;


/* "pysam/libcfaidx.pxd":72
 * 
 * # Compatibility Layer for pysam 0.8.1
 * cdef class FastqFile(FastxFile):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */

struct __pyx_vtabstruct_5pysam_9libcfaidx_FastqFile {
  struct __pyx_vtabstruct_5pysam_9libcfaidx_FastxFile __pyx_base;
};
static struct __pyx_vtabstruct_5pysam_9libcfaidx_FastqFile *__pyx_vtabptr_5pysam_9libcfaidx_FastqFile;


/* "pysam/libcfaidx.pxd":77
 * 
 * # Compatibility Layer for pysam < 0.8
 * cdef class Fastafile(FastaFile):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */

struct __pyx_vtabstruct_5pysam_9libcfaidx_Fastafile {
  struct __pyx_vtabstruct_5pysam_9libcfaidx_FastaFile __pyx_base;
};
static struct __pyx_vtabstruct_5pysam_9libcfaidx_Fastafile *__pyx_vtabptr_5pysam_9libcfaidx_Fastafile;


/* "pysam/libcalignedsegment.pxd":34
 * 
 * # Note: need to declare all C fields and methods here
 * cdef class AlignedSegment:             # <<<<<<<<<<<<<<
 * 
 *     # object that this AlignedSegment represents
 */

struct __pyx_vtabstruct_5pysam_18libcalignedsegment_AlignedSegment {
  PyObject *(*set_tag)(struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_18libcalignedsegment_14AlignedSegment_set_tag *__pyx_optional_args);
  PyObject *(*get_tag)(struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_5pysam_18libcalignedsegment_14AlignedSegment_get_tag *__pyx_optional_args);
  PyObject *(*has_tag)(struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*tostring)(struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment *, __pyx_t_5pysam_18libcalignedsegment_AlignmentFile_t, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5pysam_18libcalignedsegment_AlignedSegment *__pyx_vtabptr_5pysam_18libcalignedsegment_AlignedSegment;


/* "pysam/libcalignmentfile.pxd":39
 * 
 * 
 * cdef class AlignmentFile(HTSFile):             # <<<<<<<<<<<<<<
 *     cdef readonly object reference_filename
 * 
 */

struct __pyx_vtabstruct_5pysam_17libcalignmentfile_AlignmentFile {
  struct __pyx_vtabstruct_5pysam_10libchtslib_HTSFile __pyx_base;
  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *);
  int (*cnext)(struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *);
  int (*write)(struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *, struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5pysam_17libcalignmentfile_AlignmentFile *__pyx_vtabptr_5pysam_17libcalignmentfile_AlignmentFile;


/* "pysam/libcalignmentfile.pxd":84
 * 
 * 
 * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef hts_itr_t * iter
 *     cdef bam1_t * getCurrent(self)
 */

struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion {
  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *);
  int (*cnext)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *);
};
static struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion *__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowRegion;


/* "pysam/libcalignmentfile.pxd":89
 *     cdef int cnext(self)
 * 
 * cdef class IteratorRowHead(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef int max_rows
 *     cdef int current_row
 */

struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowHead {
  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowHead *);
  int (*cnext)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowHead *);
};
static struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowHead *__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowHead;


/* "pysam/libcalignmentfile.pxd":95
 *     cdef int cnext(self)
 * 
 * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef bam1_t * getCurrent(self)
 *     cdef int cnext(self)
 */

struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowAll {
  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowAll *);
  int (*cnext)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowAll *);
};
static struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowAll *__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowAll;


/* "pysam/libcalignmentfile.pxd":105
 * 
 * 
 * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
 *     cdef int current_pos
 *     cdef positions
 */

struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowSelection {
  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowSelection *);
  int (*cnext)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowSelection *);
};
static struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowSelection *__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowSelection;


/* "pysam/libcalignmentfile.pxd":112
 * 
 * 
 * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
 * 
 *     # result of the last plbuf_push
 */

struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumn {
  int (*cnext)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn *);
  char *(*getSequence)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn *);
  PyObject *(*setMask)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn *, PyObject *);
  PyObject *(*setupIteratorData)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn *, int, int, int, struct __pyx_opt_args_5pysam_17libcalignmentfile_14IteratorColumn_setupIteratorData *__pyx_optional_args);
  PyObject *(*reset)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn *, PyObject *, PyObject *, PyObject *);
  PyObject *(*_free_pileup_iter)(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn *);
};
static struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumn *__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumn;


/* "pysam/libcalignmentfile.pxd":141
 * 
 * 
 * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
 *     cdef int start
 *     cdef int end
 */

struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumnRegion {
  struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumn __pyx_base;
};
static struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumnRegion *__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumnRegion;


/* "pysam/libcalignmentfile.pxd":147
 * 
 * 
 * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */

struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumnAllRefs {
  struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumn __pyx_base;
};
static struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumnAllRefs *__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumnAllRefs;


/* "pysamstats/opt.pyx":74
 * 
 * 
 * cdef class PileupStat(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */

struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat {
  PyObject *(*rec)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *);
  void (*recv)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat *__pyx_vtabptr_10pysamstats_3opt_PileupStat;


/* "pysamstats/opt.pyx":89
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CountPp:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int all, pp
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CountPp {
  void (*incr)(struct __pyx_obj_10pysamstats_3opt_CountPp *, int);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *__pyx_vtabptr_10pysamstats_3opt_CountPp;


/* "pysamstats/opt.pyx":106
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Coverage(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_Coverage {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_Coverage *__pyx_vtabptr_10pysamstats_3opt_Coverage;


/* "pysamstats/opt.pyx":146
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CountPpStrand:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int all, pp, fwd, rev, pp_fwd, pp_rev
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand {
  void (*incr)(struct __pyx_obj_10pysamstats_3opt_CountPpStrand *, int, int);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *__pyx_vtabptr_10pysamstats_3opt_CountPpStrand;


/* "pysamstats/opt.pyx":171
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CoverageStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CoverageStrand {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CoverageStrand *__pyx_vtabptr_10pysamstats_3opt_CoverageStrand;


/* "pysamstats/opt.pyx":219
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CoverageExt(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CoverageExt {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CoverageExt *__pyx_vtabptr_10pysamstats_3opt_CoverageExt;


/* "pysamstats/opt.pyx":304
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CountStrand:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int all, fwd, rev
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand {
  void (*incr)(struct __pyx_obj_10pysamstats_3opt_CountStrand *, int);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *__pyx_vtabptr_10pysamstats_3opt_CountStrand;


/* "pysamstats/opt.pyx":323
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CoverageExtStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CoverageExtStrand {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CoverageExtStrand *__pyx_vtabptr_10pysamstats_3opt_CoverageExtStrand;


/* "pysamstats/opt.pyx":434
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Variation(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_Variation {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_Variation *__pyx_vtabptr_10pysamstats_3opt_Variation;


/* "pysamstats/opt.pyx":543
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class VariationStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_VariationStrand {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_VariationStrand *__pyx_vtabptr_10pysamstats_3opt_VariationStrand;


/* "pysamstats/opt.pyx":678
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class TlenHelper:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper {
  void (*update)(struct __pyx_obj_10pysamstats_3opt_TlenHelper *, int64_t);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *__pyx_vtabptr_10pysamstats_3opt_TlenHelper;


/* "pysamstats/opt.pyx":730
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Tlen(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_Tlen {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_Tlen *__pyx_vtabptr_10pysamstats_3opt_Tlen;


/* "pysamstats/opt.pyx":795
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class TlenStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_TlenStrand {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_TlenStrand *__pyx_vtabptr_10pysamstats_3opt_TlenStrand;


/* "pysamstats/opt.pyx":911
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class MapqHelper:             # <<<<<<<<<<<<<<
 *     cdef:
 *         int n
 */

struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper {
  void (*update)(struct __pyx_obj_10pysamstats_3opt_MapqHelper *, uint64_t);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *__pyx_vtabptr_10pysamstats_3opt_MapqHelper;


/* "pysamstats/opt.pyx":940
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Mapq(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_Mapq {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_Mapq *__pyx_vtabptr_10pysamstats_3opt_Mapq;


/* "pysamstats/opt.pyx":996
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class MapqStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_MapqStrand {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_MapqStrand *__pyx_vtabptr_10pysamstats_3opt_MapqStrand;


/* "pysamstats/opt.pyx":1092
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqHelper:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper {
  void (*update)(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *, int64_t);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *__pyx_vtabptr_10pysamstats_3opt_BaseqHelper;


/* "pysamstats/opt.pyx":1118
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqPpHelper:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_BaseqPpHelper {
  void (*update)(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *, int64_t, int);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_BaseqPpHelper *__pyx_vtabptr_10pysamstats_3opt_BaseqPpHelper;


/* "pysamstats/opt.pyx":1140
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class Baseq(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_Baseq {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_Baseq *__pyx_vtabptr_10pysamstats_3opt_Baseq;


/* "pysamstats/opt.pyx":1187
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqStrandPpHelper:             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrandPpHelper {
  void (*update)(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *, int64_t, int, int);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrandPpHelper *__pyx_vtabptr_10pysamstats_3opt_BaseqStrandPpHelper;


/* "pysamstats/opt.pyx":1229
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrand {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrand *__pyx_vtabptr_10pysamstats_3opt_BaseqStrand;


/* "pysamstats/opt.pyx":1291
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqExt(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_BaseqExt {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_BaseqExt *__pyx_vtabptr_10pysamstats_3opt_BaseqExt;


/* "pysamstats/opt.pyx":1366
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class BaseqExtStrand(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_BaseqExtStrand {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_BaseqExtStrand *__pyx_vtabptr_10pysamstats_3opt_BaseqExtStrand;


/* "pysamstats/opt.pyx":1470
 * 
 * # noinspection PyAttributeOutsideInit
 * cdef class CoverageGC(PileupStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef:
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CoverageGC {
  struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CoverageGC *__pyx_vtabptr_10pysamstats_3opt_CoverageGC;


/* "pysamstats/opt.pyx":1541
 * 
 * 
 * cdef class BinnedStat(object):             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):
 */

struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat {
  PyObject *(*rec)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *);
  void (*recv)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, bam1_t *);
};
static struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat *__pyx_vtabptr_10pysamstats_3opt_BinnedStat;


/* "pysamstats/opt.pyx":1550
 * 
 * 
 * cdef class CoverageBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all, reads_pp
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CoverageBinned {
  struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CoverageBinned *__pyx_vtabptr_10pysamstats_3opt_CoverageBinned;


/* "pysamstats/opt.pyx":1591
 * 
 * 
 * cdef class CoverageExtBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all, reads_pp, reads_mate_unmapped, reads_mate_other_chr, \
 */

struct __pyx_vtabstruct_10pysamstats_3opt_CoverageExtBinned {
  struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_CoverageExtBinned *__pyx_vtabptr_10pysamstats_3opt_CoverageExtBinned;


/* "pysamstats/opt.pyx":1669
 * 
 * 
 * cdef class MapqBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all, reads_mapq0
 */

struct __pyx_vtabstruct_10pysamstats_3opt_MapqBinned {
  struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_MapqBinned *__pyx_vtabptr_10pysamstats_3opt_MapqBinned;


/* "pysamstats/opt.pyx":1710
 * 
 * 
 * cdef class AlignmentBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all, M, I, D, N, S, H, P, EQ, X
 */

struct __pyx_vtabstruct_10pysamstats_3opt_AlignmentBinned {
  struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_AlignmentBinned *__pyx_vtabptr_10pysamstats_3opt_AlignmentBinned;


/* "pysamstats/opt.pyx":1771
 * 
 * 
 * cdef class TlenBinned(BinnedStat):             # <<<<<<<<<<<<<<
 * 
 *     cdef int reads_all
 */

struct __pyx_vtabstruct_10pysamstats_3opt_TlenBinned {
  struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat __pyx_base;
};
static struct __pyx_vtabstruct_10pysamstats_3opt_TlenBinned *__pyx_vtabptr_10pysamstats_3opt_TlenBinned;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#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)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
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

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

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

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

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#endif

/* PyObjectCall.proto */
#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

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyObjectCallNoArg.proto */
#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

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = PyThreadState_GET();
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

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

/* GetModuleGlobalName.proto */
static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

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

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

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_FloorDivideObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceFloorDivide(op1, op2) : PyNumber_FloorDivide(op1, op2))
#endif

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

/* PyObjectCallMethod0.proto */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

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

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

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

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

/* dict_iter.proto */
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);

/* MergeKeywords.proto */
static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping);

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

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

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
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

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
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

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_TrueDivideObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
#endif

/* PySequenceContains.proto */
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));
}

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
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

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

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

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

/* CallNextTpClear.proto */
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);

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

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

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\
    PyObject_RichCompare(op1, op2, Py_EQ)
    #endif

/* GetItemInt.proto */
#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);

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __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);

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

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* None.proto */
static CYTHON_INLINE int64_t __Pyx_pow_int64_t(int64_t, int64_t);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value);

/* None.proto */
static CYTHON_INLINE uint64_t __Pyx_pow_uint64_t(uint64_t, uint64_t);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value);

/* ArrayAPI.proto */
#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->allocated && n*4 > self->allocated) {
        self->ob_size = n;
        return 0;
    }
    newsize = n + (n / 2) + 1;
    if (newsize <= n) {
        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

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

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

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* CoroutineBase.proto */
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;
    PyObject *gi_modulename;
    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, PyObject *module_name);
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

/* PatchModuleWithCoroutine.proto */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

/* PatchGeneratorABC.proto */
static int __Pyx_patch_abc(void);

/* Generator.proto */
#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, module_name)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, closure, name, qualname, module_name)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* PyIdentifierFromString.proto */
#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

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

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

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

static PyObject *__pyx_f_10pysamstats_3opt_10PileupStat_rec(CYTHON_UNUSED struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_10PileupStat_recv(CYTHON_UNUSED struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_self, CYTHON_UNUSED bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_7CountPp_incr(struct __pyx_obj_10pysamstats_3opt_CountPp *__pyx_v_self, int __pyx_v_is_proper_pair); /* proto*/
static void __pyx_f_10pysamstats_3opt_8Coverage_recv(struct __pyx_obj_10pysamstats_3opt_Coverage *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_8Coverage_rec(struct __pyx_obj_10pysamstats_3opt_Coverage *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_13CountPpStrand_incr(struct __pyx_obj_10pysamstats_3opt_CountPpStrand *__pyx_v_self, int __pyx_v_is_reverse, int __pyx_v_is_proper_pair); /* proto*/
static void __pyx_f_10pysamstats_3opt_14CoverageStrand_recv(struct __pyx_obj_10pysamstats_3opt_CoverageStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_14CoverageStrand_rec(struct __pyx_obj_10pysamstats_3opt_CoverageStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_11CoverageExt_recv(struct __pyx_obj_10pysamstats_3opt_CoverageExt *__pyx_v_self, bam_pileup1_t *__pyx_v_read, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_11CoverageExt_rec(struct __pyx_obj_10pysamstats_3opt_CoverageExt *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_11CountStrand_incr(struct __pyx_obj_10pysamstats_3opt_CountStrand *__pyx_v_self, int __pyx_v_is_reverse); /* proto*/
static void __pyx_f_10pysamstats_3opt_17CoverageExtStrand_recv(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_17CoverageExtStrand_rec(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_9Variation_recv(struct __pyx_obj_10pysamstats_3opt_Variation *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_9Variation_rec(struct __pyx_obj_10pysamstats_3opt_Variation *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_15VariationStrand_recv(struct __pyx_obj_10pysamstats_3opt_VariationStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_15VariationStrand_rec(struct __pyx_obj_10pysamstats_3opt_VariationStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_10TlenHelper_update(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self, int64_t __pyx_v_x); /* proto*/
static void __pyx_f_10pysamstats_3opt_4Tlen_recv(struct __pyx_obj_10pysamstats_3opt_Tlen *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_4Tlen_rec(struct __pyx_obj_10pysamstats_3opt_Tlen *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_10TlenStrand_recv(struct __pyx_obj_10pysamstats_3opt_TlenStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_10TlenStrand_rec(struct __pyx_obj_10pysamstats_3opt_TlenStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_10MapqHelper_update(struct __pyx_obj_10pysamstats_3opt_MapqHelper *__pyx_v_self, uint64_t __pyx_v_mapq); /* proto*/
static void __pyx_f_10pysamstats_3opt_4Mapq_recv(struct __pyx_obj_10pysamstats_3opt_Mapq *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_4Mapq_rec(struct __pyx_obj_10pysamstats_3opt_Mapq *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_10MapqStrand_recv(struct __pyx_obj_10pysamstats_3opt_MapqStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_10MapqStrand_rec(struct __pyx_obj_10pysamstats_3opt_MapqStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_11BaseqHelper_update(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *__pyx_v_self, int64_t __pyx_v_baseq_squared); /* proto*/
static void __pyx_f_10pysamstats_3opt_13BaseqPpHelper_update(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *__pyx_v_self, int64_t __pyx_v_baseq_squared, int __pyx_v_is_proper_pair); /* proto*/
static void __pyx_f_10pysamstats_3opt_5Baseq_recv(struct __pyx_obj_10pysamstats_3opt_Baseq *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_5Baseq_rec(struct __pyx_obj_10pysamstats_3opt_Baseq *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_19BaseqStrandPpHelper_update(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *__pyx_v_self, int64_t __pyx_v_baseq_squared, int __pyx_v_is_proper_pair, int __pyx_v_is_reverse); /* proto*/
static void __pyx_f_10pysamstats_3opt_11BaseqStrand_recv(struct __pyx_obj_10pysamstats_3opt_BaseqStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_11BaseqStrand_rec(struct __pyx_obj_10pysamstats_3opt_BaseqStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_8BaseqExt_recv(struct __pyx_obj_10pysamstats_3opt_BaseqExt *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_8BaseqExt_rec(struct __pyx_obj_10pysamstats_3opt_BaseqExt *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_14BaseqExtStrand_recv(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_14BaseqExtStrand_rec(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_refbase); /* proto*/
static void __pyx_f_10pysamstats_3opt_10CoverageGC_recv(struct __pyx_obj_10pysamstats_3opt_CoverageGC *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_10CoverageGC_rec(struct __pyx_obj_10pysamstats_3opt_CoverageGC *__pyx_v_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_pos, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_10BinnedStat_rec(CYTHON_UNUSED struct __pyx_obj_10pysamstats_3opt_BinnedStat *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_bin_start, CYTHON_UNUSED PyObject *__pyx_v_bin_end, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile); /* proto*/
static void __pyx_f_10pysamstats_3opt_10BinnedStat_recv(CYTHON_UNUSED struct __pyx_obj_10pysamstats_3opt_BinnedStat *__pyx_v_self, CYTHON_UNUSED bam1_t *__pyx_v_b); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_14CoverageBinned_rec(struct __pyx_obj_10pysamstats_3opt_CoverageBinned *__pyx_v_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_bin_start, PyObject *__pyx_v_bin_end, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile); /* proto*/
static void __pyx_f_10pysamstats_3opt_14CoverageBinned_recv(struct __pyx_obj_10pysamstats_3opt_CoverageBinned *__pyx_v_self, bam1_t *__pyx_v_b); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_17CoverageExtBinned_rec(struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned *__pyx_v_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_bin_start, PyObject *__pyx_v_bin_end, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile); /* proto*/
static void __pyx_f_10pysamstats_3opt_17CoverageExtBinned_recv(struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned *__pyx_v_self, bam1_t *__pyx_v_b); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_10MapqBinned_rec(struct __pyx_obj_10pysamstats_3opt_MapqBinned *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_bin_start, CYTHON_UNUSED PyObject *__pyx_v_bin_end, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile); /* proto*/
static void __pyx_f_10pysamstats_3opt_10MapqBinned_recv(struct __pyx_obj_10pysamstats_3opt_MapqBinned *__pyx_v_self, bam1_t *__pyx_v_b); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_15AlignmentBinned_rec(struct __pyx_obj_10pysamstats_3opt_AlignmentBinned *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_bin_start, CYTHON_UNUSED PyObject *__pyx_v_bin_end, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile); /* proto*/
static void __pyx_f_10pysamstats_3opt_15AlignmentBinned_recv(struct __pyx_obj_10pysamstats_3opt_AlignmentBinned *__pyx_v_self, bam1_t *__pyx_v_b); /* proto*/
static PyObject *__pyx_f_10pysamstats_3opt_10TlenBinned_rec(struct __pyx_obj_10pysamstats_3opt_TlenBinned *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_bin_start, CYTHON_UNUSED PyObject *__pyx_v_bin_end, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile); /* proto*/
static void __pyx_f_10pysamstats_3opt_10TlenBinned_recv(struct __pyx_obj_10pysamstats_3opt_TlenBinned *__pyx_v_self, bam1_t *__pyx_v_b); /* proto*/

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

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

/* 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 'libc.stdlib' */

/* Module declarations from 'posix.types' */

/* Module declarations from 'pysam.libchtslib' */
static PyTypeObject *__pyx_ptype_5pysam_10libchtslib_HTSFile = 0;

/* Module declarations from 'cython' */

/* Module declarations from 'array' */

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

/* Module declarations from 'pysam.libcfaidx' */
static PyTypeObject *__pyx_ptype_5pysam_9libcfaidx_FastaFile = 0;
static PyTypeObject *__pyx_ptype_5pysam_9libcfaidx_FastqProxy = 0;
static PyTypeObject *__pyx_ptype_5pysam_9libcfaidx_PersistentFastqProxy = 0;
static PyTypeObject *__pyx_ptype_5pysam_9libcfaidx_FastxFile = 0;
static PyTypeObject *__pyx_ptype_5pysam_9libcfaidx_FastqFile = 0;
static PyTypeObject *__pyx_ptype_5pysam_9libcfaidx_Fastafile = 0;

/* Module declarations from 'pysam.libcalignedsegment' */
static PyTypeObject *__pyx_ptype_5pysam_18libcalignedsegment_AlignedSegment = 0;
static PyTypeObject *__pyx_ptype_5pysam_18libcalignedsegment_PileupColumn = 0;
static PyTypeObject *__pyx_ptype_5pysam_18libcalignedsegment_PileupRead = 0;

/* Module declarations from 'pysam.libcalignmentfile' */
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_PileupColumn = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_PileupRead = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorRow = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowRegion = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowHead = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowAll = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowAllRefs = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowSelection = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumn = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumnRegion = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumnAllRefs = 0;
static PyTypeObject *__pyx_ptype_5pysam_17libcalignmentfile_IndexedReads = 0;

/* Module declarations from 'pysamstats.opt' */
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_PileupStat = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CountPp = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_Coverage = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CountPpStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CoverageStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CoverageExt = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CountStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CoverageExtStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_Variation = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_VariationStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_TlenHelper = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_Tlen = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_TlenStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_MapqHelper = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_Mapq = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_MapqStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_BaseqHelper = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_BaseqPpHelper = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_Baseq = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_BaseqStrandPpHelper = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_BaseqStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_BaseqExt = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_BaseqExtStrand = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CoverageGC = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_BinnedStat = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CoverageBinned = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_CoverageExtBinned = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_MapqBinned = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_AlignmentBinned = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt_TlenBinned = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom = 0;
static PyTypeObject *__pyx_ptype_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom = 0;
static char *__pyx_v_10pysamstats_3opt_CODE2CIGAR;
static char *__pyx_v_10pysamstats_3opt_bam_nt16_rev_table;
static int __pyx_f_10pysamstats_3opt_gc_content(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_10pysamstats_3opt_is_softclipped(bam1_t *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_10pysamstats_3opt_get_seq_base(bam1_t *, uint32_t); /*proto*/
#define __Pyx_MODULE_NAME "pysamstats.opt"
int __pyx_module_is_main_pysamstats__opt = 0;

/* Implementation of 'pysamstats.opt' */
static PyObject *__pyx_builtin_round;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_MemoryError;
static const char __pyx_k_A[] = "A";
static const char __pyx_k_C[] = "C";
static const char __pyx_k_D[] = "D";
static const char __pyx_k_G[] = "G";
static const char __pyx_k_H[] = "H";
static const char __pyx_k_I[] = "I";
static const char __pyx_k_M[] = "M";
static const char __pyx_k_N[] = "N";
static const char __pyx_k_P[] = "P";
static const char __pyx_k_S[] = "S";
static const char __pyx_k_T[] = "T";
static const char __pyx_k_X[] = "X";
static const char __pyx_k_b[] = "b";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_n[] = "n";
static const char __pyx_k__2[] = "=";
static const char __pyx_k_gc[] = "gc";
static const char __pyx_k_it[] = "it";
static const char __pyx_k_PY2[] = "PY2";
static const char __pyx_k_col[] = "col";
static const char __pyx_k_end[] = "end";
static const char __pyx_k_itc[] = "itc";
static const char __pyx_k_its[] = "its";
static const char __pyx_k_pad[] = "pad";
static const char __pyx_k_plp[] = "plp";
static const char __pyx_k_pos[] = "pos";
static const char __pyx_k_rec[] = "rec";
static const char __pyx_k_ref[] = "ref";
static const char __pyx_k_rms[] = "rms";
static const char __pyx_k_std[] = "std";
static const char __pyx_k_sys[] = "sys";
static const char __pyx_k_A_pp[] = "A_pp";
static const char __pyx_k_C_pp[] = "C_pp";
static const char __pyx_k_G_pp[] = "G_pp";
static const char __pyx_k_N_pp[] = "N_pp";
static const char __pyx_k_T_pp[] = "T_pp";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mean[] = "mean";
static const char __pyx_k_read[] = "read";
static const char __pyx_k_rend[] = "rend";
static const char __pyx_k_rtid[] = "rtid";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_stat[] = "stat";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_A_fwd[] = "A_fwd";
static const char __pyx_k_A_rev[] = "A_rev";
static const char __pyx_k_C_fwd[] = "C_fwd";
static const char __pyx_k_C_rev[] = "C_rev";
static const char __pyx_k_G_fwd[] = "G_fwd";
static const char __pyx_k_G_rev[] = "G_rev";
static const char __pyx_k_N_fwd[] = "N_fwd";
static const char __pyx_k_N_rev[] = "N_rev";
static const char __pyx_k_T_fwd[] = "T_fwd";
static const char __pyx_k_T_rev[] = "T_rev";
static const char __pyx_k_ascii[] = "ascii";
static const char __pyx_k_chain[] = "chain";
static const char __pyx_k_chrom[] = "chrom";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_count[] = "count";
static const char __pyx_k_fetch[] = "fetch";
static const char __pyx_k_index[] = "index";
static const char __pyx_k_items[] = "items";
static const char __pyx_k_lower[] = "lower";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_reset[] = "reset";
static const char __pyx_k_round[] = "round";
static const char __pyx_k_sqsum[] = "sqsum";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_sys_2[] = "_sys";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_total[] = "total";
static const char __pyx_k_upper[] = "upper";
static const char __pyx_k_chrlen[] = "chrlen";
static const char __pyx_k_curpos[] = "curpos";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_fafile[] = "fafile";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_no_del[] = "no_del";
static const char __pyx_k_no_dup[] = "no_dup";
static const char __pyx_k_pileup[] = "pileup";
static const char __pyx_k_rstart[] = "rstart";
static const char __pyx_k_bin_end[] = "bin_end";
static const char __pyx_k_lengths[] = "lengths";
static const char __pyx_k_matches[] = "matches";
static const char __pyx_k_refbase[] = "refbase";
static const char __pyx_k_A_pp_fwd[] = "A_pp_fwd";
static const char __pyx_k_A_pp_rev[] = "A_pp_rev";
static const char __pyx_k_C_pp_fwd[] = "C_pp_fwd";
static const char __pyx_k_C_pp_rev[] = "C_pp_rev";
static const char __pyx_k_G_pp_fwd[] = "G_pp_fwd";
static const char __pyx_k_G_pp_rev[] = "G_pp_rev";
static const char __pyx_k_N_pp_fwd[] = "N_pp_fwd";
static const char __pyx_k_N_pp_rev[] = "N_pp_rev";
static const char __pyx_k_T_pp_fwd[] = "T_pp_fwd";
static const char __pyx_k_T_pp_rev[] = "T_pp_rev";
static const char __pyx_k_getrname[] = "getrname";
static const char __pyx_k_max_mapq[] = "max_mapq";
static const char __pyx_k_min_mapq[] = "min_mapq";
static const char __pyx_k_reads_pp[] = "reads_pp";
static const char __pyx_k_rms_mapq[] = "rms_mapq";
static const char __pyx_k_rms_tlen[] = "rms_tlen";
static const char __pyx_k_rootmean[] = "rootmean";
static const char __pyx_k_std_tlen[] = "std_tlen";
static const char __pyx_k_truncate[] = "truncate";
static const char __pyx_k_bases_all[] = "bases_all";
static const char __pyx_k_bin_start[] = "bin_start";
static const char __pyx_k_deletions[] = "deletions";
static const char __pyx_k_has_coord[] = "has_coord";
static const char __pyx_k_itertools[] = "itertools";
static const char __pyx_k_max_depth[] = "max_depth";
static const char __pyx_k_mean_tlen[] = "mean_tlen";
static const char __pyx_k_min_baseq[] = "min_baseq";
static const char __pyx_k_one_based[] = "one_based";
static const char __pyx_k_reads_all[] = "reads_all";
static const char __pyx_k_reads_fwd[] = "reads_fwd";
static const char __pyx_k_reads_rev[] = "reads_rev";
static const char __pyx_k_reference[] = "reference";
static const char __pyx_k_rms_baseq[] = "rms_baseq";
static const char __pyx_k_insertions[] = "insertions";
static const char __pyx_k_matches_pp[] = "matches_pp";
static const char __pyx_k_mismatches[] = "mismatches";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_references[] = "references";
static const char __pyx_k_MemoryError[] = "MemoryError";
static const char __pyx_k_count_reads[] = "count_reads";
static const char __pyx_k_get_refbase[] = "get_refbase";
static const char __pyx_k_iter_binned[] = "iter_binned";
static const char __pyx_k_iter_pileup[] = "iter_pileup";
static const char __pyx_k_matches_fwd[] = "matches_fwd";
static const char __pyx_k_matches_rev[] = "matches_rev";
static const char __pyx_k_max_mapq_pp[] = "max_mapq_pp";
static const char __pyx_k_reads_mapq0[] = "reads_mapq0";
static const char __pyx_k_rms_mapq_pp[] = "rms_mapq_pp";
static const char __pyx_k_rms_tlen_pp[] = "rms_tlen_pp";
static const char __pyx_k_stat_pileup[] = "stat_pileup";
static const char __pyx_k_std_tlen_pp[] = "std_tlen_pp";
static const char __pyx_k_window_size[] = "window_size";
static const char __pyx_k_deletions_pp[] = "deletions_pp";
static const char __pyx_k_max_mapq_fwd[] = "max_mapq_fwd";
static const char __pyx_k_max_mapq_rev[] = "max_mapq_rev";
static const char __pyx_k_mean_tlen_pp[] = "mean_tlen_pp";
static const char __pyx_k_parse_region[] = "parse_region";
static const char __pyx_k_reads_paired[] = "reads_paired";
static const char __pyx_k_reads_pp_fwd[] = "reads_pp_fwd";
static const char __pyx_k_reads_pp_rev[] = "reads_pp_rev";
static const char __pyx_k_rms_baseq_pp[] = "rms_baseq_pp";
static const char __pyx_k_rms_mapq_fwd[] = "rms_mapq_fwd";
static const char __pyx_k_rms_mapq_rev[] = "rms_mapq_rev";
static const char __pyx_k_rms_tlen_fwd[] = "rms_tlen_fwd";
static const char __pyx_k_rms_tlen_rev[] = "rms_tlen_rev";
static const char __pyx_k_std_tlen_fwd[] = "std_tlen_fwd";
static const char __pyx_k_std_tlen_rev[] = "std_tlen_rev";
static const char __pyx_k_string_types[] = "_string_types";
static const char __pyx_k_version_info[] = "version_info";
static const char __pyx_k_alignmentfile[] = "alignmentfile";
static const char __pyx_k_deletions_fwd[] = "deletions_fwd";
static const char __pyx_k_deletions_rev[] = "deletions_rev";
static const char __pyx_k_insertions_pp[] = "insertions_pp";
static const char __pyx_k_mean_tlen_fwd[] = "mean_tlen_fwd";
static const char __pyx_k_mean_tlen_rev[] = "mean_tlen_rev";
static const char __pyx_k_mismatches_pp[] = "mismatches_pp";
static const char __pyx_k_rms_baseq_fwd[] = "rms_baseq_fwd";
static const char __pyx_k_rms_baseq_rev[] = "rms_baseq_rev";
static const char __pyx_k_window_offset[] = "window_offset";
static const char __pyx_k_insertions_fwd[] = "insertions_fwd";
static const char __pyx_k_insertions_rev[] = "insertions_rev";
static const char __pyx_k_matches_pp_fwd[] = "matches_pp_fwd";
static const char __pyx_k_matches_pp_rev[] = "matches_pp_rev";
static const char __pyx_k_mismatches_fwd[] = "mismatches_fwd";
static const char __pyx_k_mismatches_rev[] = "mismatches_rev";
static const char __pyx_k_pysamstats_opt[] = "pysamstats.opt";
static const char __pyx_k_reads_faceaway[] = "reads_faceaway";
static const char __pyx_k_reads_mapq0_pp[] = "reads_mapq0_pp";
static const char __pyx_k_max_mapq_pp_fwd[] = "max_mapq_pp_fwd";
static const char __pyx_k_max_mapq_pp_rev[] = "max_mapq_pp_rev";
static const char __pyx_k_reads_duplicate[] = "reads_duplicate";
static const char __pyx_k_reads_mapq0_fwd[] = "reads_mapq0_fwd";
static const char __pyx_k_reads_mapq0_rev[] = "reads_mapq0_rev";
static const char __pyx_k_rms_mapq_pp_fwd[] = "rms_mapq_pp_fwd";
static const char __pyx_k_rms_mapq_pp_rev[] = "rms_mapq_pp_rev";
static const char __pyx_k_rms_tlen_pp_fwd[] = "rms_tlen_pp_fwd";
static const char __pyx_k_rms_tlen_pp_rev[] = "rms_tlen_pp_rev";
static const char __pyx_k_std_tlen_pp_fwd[] = "std_tlen_pp_fwd";
static const char __pyx_k_std_tlen_pp_rev[] = "std_tlen_pp_rev";
static const char __pyx_k_deletions_pp_fwd[] = "deletions_pp_fwd";
static const char __pyx_k_deletions_pp_rev[] = "deletions_pp_rev";
static const char __pyx_k_mean_tlen_pp_fwd[] = "mean_tlen_pp_fwd";
static const char __pyx_k_mean_tlen_pp_rev[] = "mean_tlen_pp_rev";
static const char __pyx_k_normalise_coords[] = "normalise_coords";
static const char __pyx_k_reads_paired_fwd[] = "reads_paired_fwd";
static const char __pyx_k_reads_paired_rev[] = "reads_paired_rev";
static const char __pyx_k_rms_baseq_pp_fwd[] = "rms_baseq_pp_fwd";
static const char __pyx_k_rms_baseq_pp_rev[] = "rms_baseq_pp_rev";
static const char __pyx_k_insertions_pp_fwd[] = "insertions_pp_fwd";
static const char __pyx_k_insertions_pp_rev[] = "insertions_pp_rev";
static const char __pyx_k_iter_binned_chrom[] = "iter_binned_chrom";
static const char __pyx_k_mismatches_pp_fwd[] = "mismatches_pp_fwd";
static const char __pyx_k_mismatches_pp_rev[] = "mismatches_pp_rev";
static const char __pyx_k_reads_softclipped[] = "reads_softclipped";
static const char __pyx_k_rms_baseq_matches[] = "rms_baseq_matches";
static const char __pyx_k_chromosome_is_None[] = "chromosome is None";
static const char __pyx_k_iter_pileup_padded[] = "iter_pileup_padded";
static const char __pyx_k_multiple_iterators[] = "multiple_iterators";
static const char __pyx_k_reads_faceaway_fwd[] = "reads_faceaway_fwd";
static const char __pyx_k_reads_faceaway_rev[] = "reads_faceaway_rev";
static const char __pyx_k_reads_mapq0_pp_fwd[] = "reads_mapq0_pp_fwd";
static const char __pyx_k_reads_mapq0_pp_rev[] = "reads_mapq0_pp_rev";
static const char __pyx_k_iter_pileup_default[] = "iter_pileup_default";
static const char __pyx_k_reads_duplicate_fwd[] = "reads_duplicate_fwd";
static const char __pyx_k_reads_duplicate_rev[] = "reads_duplicate_rev";
static const char __pyx_k_reads_mate_unmapped[] = "reads_mate_unmapped";
static const char __pyx_k_reads_mate_other_chr[] = "reads_mate_other_chr";
static const char __pyx_k_rms_baseq_matches_pp[] = "rms_baseq_matches_pp";
static const char __pyx_k_rms_baseq_mismatches[] = "rms_baseq_mismatches";
static const char __pyx_k_reads_softclipped_fwd[] = "reads_softclipped_fwd";
static const char __pyx_k_reads_softclipped_rev[] = "reads_softclipped_rev";
static const char __pyx_k_rms_baseq_matches_fwd[] = "rms_baseq_matches_fwd";
static const char __pyx_k_rms_baseq_matches_rev[] = "rms_baseq_matches_rev";
static const char __pyx_k_reads_mate_same_strand[] = "reads_mate_same_strand";
static const char __pyx_k_reads_mate_unmapped_fwd[] = "reads_mate_unmapped_fwd";
static const char __pyx_k_reads_mate_unmapped_rev[] = "reads_mate_unmapped_rev";
static const char __pyx_k_rms_baseq_mismatches_pp[] = "rms_baseq_mismatches_pp";
static const char __pyx_k_iter_pileup_padded_chrom[] = "iter_pileup_padded_chrom";
static const char __pyx_k_reads_mate_other_chr_fwd[] = "reads_mate_other_chr_fwd";
static const char __pyx_k_reads_mate_other_chr_rev[] = "reads_mate_other_chr_rev";
static const char __pyx_k_rms_baseq_matches_pp_fwd[] = "rms_baseq_matches_pp_fwd";
static const char __pyx_k_rms_baseq_matches_pp_rev[] = "rms_baseq_matches_pp_rev";
static const char __pyx_k_rms_baseq_mismatches_fwd[] = "rms_baseq_mismatches_fwd";
static const char __pyx_k_rms_baseq_mismatches_rev[] = "rms_baseq_mismatches_rev";
static const char __pyx_k_reads_mate_same_strand_fwd[] = "reads_mate_same_strand_fwd";
static const char __pyx_k_reads_mate_same_strand_rev[] = "reads_mate_same_strand_rev";
static const char __pyx_k_rms_baseq_mismatches_pp_fwd[] = "rms_baseq_mismatches_pp_fwd";
static const char __pyx_k_rms_baseq_mismatches_pp_rev[] = "rms_baseq_mismatches_pp_rev";
static const char __pyx_k_home_aliman_src_github_alimanfo[] = "/home/aliman/src/github/alimanfoo/pysamstats/pysamstats/opt.pyx";
static const char __pyx_k_chromosome_not_in_SAM_references[] = "chromosome not in SAM references: %s";
static PyObject *__pyx_n_b_A;
static PyObject *__pyx_n_s_A;
static PyObject *__pyx_n_s_A_fwd;
static PyObject *__pyx_n_s_A_pp;
static PyObject *__pyx_n_s_A_pp_fwd;
static PyObject *__pyx_n_s_A_pp_rev;
static PyObject *__pyx_n_s_A_rev;
static PyObject *__pyx_n_b_C;
static PyObject *__pyx_n_s_C;
static PyObject *__pyx_n_s_C_fwd;
static PyObject *__pyx_n_s_C_pp;
static PyObject *__pyx_n_s_C_pp_fwd;
static PyObject *__pyx_n_s_C_pp_rev;
static PyObject *__pyx_n_s_C_rev;
static PyObject *__pyx_n_s_D;
static PyObject *__pyx_n_b_G;
static PyObject *__pyx_n_s_G;
static PyObject *__pyx_n_s_G_fwd;
static PyObject *__pyx_n_s_G_pp;
static PyObject *__pyx_n_s_G_pp_fwd;
static PyObject *__pyx_n_s_G_pp_rev;
static PyObject *__pyx_n_s_G_rev;
static PyObject *__pyx_n_s_H;
static PyObject *__pyx_n_s_I;
static PyObject *__pyx_n_s_M;
static PyObject *__pyx_n_s_MemoryError;
static PyObject *__pyx_n_b_N;
static PyObject *__pyx_n_s_N;
static PyObject *__pyx_n_s_N_fwd;
static PyObject *__pyx_n_s_N_pp;
static PyObject *__pyx_n_s_N_pp_fwd;
static PyObject *__pyx_n_s_N_pp_rev;
static PyObject *__pyx_n_s_N_rev;
static PyObject *__pyx_n_s_P;
static PyObject *__pyx_n_s_PY2;
static PyObject *__pyx_n_s_S;
static PyObject *__pyx_n_b_T;
static PyObject *__pyx_n_s_T;
static PyObject *__pyx_n_s_T_fwd;
static PyObject *__pyx_n_s_T_pp;
static PyObject *__pyx_n_s_T_pp_fwd;
static PyObject *__pyx_n_s_T_pp_rev;
static PyObject *__pyx_n_s_T_rev;
static PyObject *__pyx_n_s_X;
static PyObject *__pyx_kp_s__2;
static PyObject *__pyx_n_s_alignmentfile;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_ascii;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_n_s_bases_all;
static PyObject *__pyx_n_s_bin_end;
static PyObject *__pyx_n_s_bin_start;
static PyObject *__pyx_n_s_chain;
static PyObject *__pyx_n_s_chrlen;
static PyObject *__pyx_n_s_chrom;
static PyObject *__pyx_kp_s_chromosome_is_None;
static PyObject *__pyx_kp_s_chromosome_not_in_SAM_references;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_col;
static PyObject *__pyx_n_s_count;
static PyObject *__pyx_n_s_count_reads;
static PyObject *__pyx_n_s_curpos;
static PyObject *__pyx_n_s_deletions;
static PyObject *__pyx_n_s_deletions_fwd;
static PyObject *__pyx_n_s_deletions_pp;
static PyObject *__pyx_n_s_deletions_pp_fwd;
static PyObject *__pyx_n_s_deletions_pp_rev;
static PyObject *__pyx_n_s_deletions_rev;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_fafile;
static PyObject *__pyx_n_s_fetch;
static PyObject *__pyx_n_s_gc;
static PyObject *__pyx_n_s_get_refbase;
static PyObject *__pyx_n_s_getrname;
static PyObject *__pyx_n_s_has_coord;
static PyObject *__pyx_kp_s_home_aliman_src_github_alimanfo;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_insertions;
static PyObject *__pyx_n_s_insertions_fwd;
static PyObject *__pyx_n_s_insertions_pp;
static PyObject *__pyx_n_s_insertions_pp_fwd;
static PyObject *__pyx_n_s_insertions_pp_rev;
static PyObject *__pyx_n_s_insertions_rev;
static PyObject *__pyx_n_s_it;
static PyObject *__pyx_n_s_itc;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_iter_binned;
static PyObject *__pyx_n_s_iter_binned_chrom;
static PyObject *__pyx_n_s_iter_pileup;
static PyObject *__pyx_n_s_iter_pileup_default;
static PyObject *__pyx_n_s_iter_pileup_padded;
static PyObject *__pyx_n_s_iter_pileup_padded_chrom;
static PyObject *__pyx_n_s_itertools;
static PyObject *__pyx_n_s_its;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_lengths;
static PyObject *__pyx_n_s_lower;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_matches;
static PyObject *__pyx_n_s_matches_fwd;
static PyObject *__pyx_n_s_matches_pp;
static PyObject *__pyx_n_s_matches_pp_fwd;
static PyObject *__pyx_n_s_matches_pp_rev;
static PyObject *__pyx_n_s_matches_rev;
static PyObject *__pyx_n_s_max_depth;
static PyObject *__pyx_n_s_max_mapq;
static PyObject *__pyx_n_s_max_mapq_fwd;
static PyObject *__pyx_n_s_max_mapq_pp;
static PyObject *__pyx_n_s_max_mapq_pp_fwd;
static PyObject *__pyx_n_s_max_mapq_pp_rev;
static PyObject *__pyx_n_s_max_mapq_rev;
static PyObject *__pyx_n_s_mean;
static PyObject *__pyx_n_s_mean_tlen;
static PyObject *__pyx_n_s_mean_tlen_fwd;
static PyObject *__pyx_n_s_mean_tlen_pp;
static PyObject *__pyx_n_s_mean_tlen_pp_fwd;
static PyObject *__pyx_n_s_mean_tlen_pp_rev;
static PyObject *__pyx_n_s_mean_tlen_rev;
static PyObject *__pyx_n_s_min_baseq;
static PyObject *__pyx_n_s_min_mapq;
static PyObject *__pyx_n_s_mismatches;
static PyObject *__pyx_n_s_mismatches_fwd;
static PyObject *__pyx_n_s_mismatches_pp;
static PyObject *__pyx_n_s_mismatches_pp_fwd;
static PyObject *__pyx_n_s_mismatches_pp_rev;
static PyObject *__pyx_n_s_mismatches_rev;
static PyObject *__pyx_n_s_multiple_iterators;
static PyObject *__pyx_n_s_n;
static PyObject *__pyx_n_s_no_del;
static PyObject *__pyx_n_s_no_dup;
static PyObject *__pyx_n_s_normalise_coords;
static PyObject *__pyx_n_s_one_based;
static PyObject *__pyx_n_s_pad;
static PyObject *__pyx_n_s_parse_region;
static PyObject *__pyx_n_s_pileup;
static PyObject *__pyx_n_s_plp;
static PyObject *__pyx_n_s_pos;
static PyObject *__pyx_n_s_pysamstats_opt;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_read;
static PyObject *__pyx_n_s_reads_all;
static PyObject *__pyx_n_s_reads_duplicate;
static PyObject *__pyx_n_s_reads_duplicate_fwd;
static PyObject *__pyx_n_s_reads_duplicate_rev;
static PyObject *__pyx_n_s_reads_faceaway;
static PyObject *__pyx_n_s_reads_faceaway_fwd;
static PyObject *__pyx_n_s_reads_faceaway_rev;
static PyObject *__pyx_n_s_reads_fwd;
static PyObject *__pyx_n_s_reads_mapq0;
static PyObject *__pyx_n_s_reads_mapq0_fwd;
static PyObject *__pyx_n_s_reads_mapq0_pp;
static PyObject *__pyx_n_s_reads_mapq0_pp_fwd;
static PyObject *__pyx_n_s_reads_mapq0_pp_rev;
static PyObject *__pyx_n_s_reads_mapq0_rev;
static PyObject *__pyx_n_s_reads_mate_other_chr;
static PyObject *__pyx_n_s_reads_mate_other_chr_fwd;
static PyObject *__pyx_n_s_reads_mate_other_chr_rev;
static PyObject *__pyx_n_s_reads_mate_same_strand;
static PyObject *__pyx_n_s_reads_mate_same_strand_fwd;
static PyObject *__pyx_n_s_reads_mate_same_strand_rev;
static PyObject *__pyx_n_s_reads_mate_unmapped;
static PyObject *__pyx_n_s_reads_mate_unmapped_fwd;
static PyObject *__pyx_n_s_reads_mate_unmapped_rev;
static PyObject *__pyx_n_s_reads_paired;
static PyObject *__pyx_n_s_reads_paired_fwd;
static PyObject *__pyx_n_s_reads_paired_rev;
static PyObject *__pyx_n_s_reads_pp;
static PyObject *__pyx_n_s_reads_pp_fwd;
static PyObject *__pyx_n_s_reads_pp_rev;
static PyObject *__pyx_n_s_reads_rev;
static PyObject *__pyx_n_s_reads_softclipped;
static PyObject *__pyx_n_s_reads_softclipped_fwd;
static PyObject *__pyx_n_s_reads_softclipped_rev;
static PyObject *__pyx_n_s_rec;
static PyObject *__pyx_n_s_ref;
static PyObject *__pyx_n_s_refbase;
static PyObject *__pyx_n_s_reference;
static PyObject *__pyx_n_s_references;
static PyObject *__pyx_n_s_rend;
static PyObject *__pyx_n_s_reset;
static PyObject *__pyx_n_s_rms;
static PyObject *__pyx_n_s_rms_baseq;
static PyObject *__pyx_n_s_rms_baseq_fwd;
static PyObject *__pyx_n_s_rms_baseq_matches;
static PyObject *__pyx_n_s_rms_baseq_matches_fwd;
static PyObject *__pyx_n_s_rms_baseq_matches_pp;
static PyObject *__pyx_n_s_rms_baseq_matches_pp_fwd;
static PyObject *__pyx_n_s_rms_baseq_matches_pp_rev;
static PyObject *__pyx_n_s_rms_baseq_matches_rev;
static PyObject *__pyx_n_s_rms_baseq_mismatches;
static PyObject *__pyx_n_s_rms_baseq_mismatches_fwd;
static PyObject *__pyx_n_s_rms_baseq_mismatches_pp;
static PyObject *__pyx_n_s_rms_baseq_mismatches_pp_fwd;
static PyObject *__pyx_n_s_rms_baseq_mismatches_pp_rev;
static PyObject *__pyx_n_s_rms_baseq_mismatches_rev;
static PyObject *__pyx_n_s_rms_baseq_pp;
static PyObject *__pyx_n_s_rms_baseq_pp_fwd;
static PyObject *__pyx_n_s_rms_baseq_pp_rev;
static PyObject *__pyx_n_s_rms_baseq_rev;
static PyObject *__pyx_n_s_rms_mapq;
static PyObject *__pyx_n_s_rms_mapq_fwd;
static PyObject *__pyx_n_s_rms_mapq_pp;
static PyObject *__pyx_n_s_rms_mapq_pp_fwd;
static PyObject *__pyx_n_s_rms_mapq_pp_rev;
static PyObject *__pyx_n_s_rms_mapq_rev;
static PyObject *__pyx_n_s_rms_tlen;
static PyObject *__pyx_n_s_rms_tlen_fwd;
static PyObject *__pyx_n_s_rms_tlen_pp;
static PyObject *__pyx_n_s_rms_tlen_pp_fwd;
static PyObject *__pyx_n_s_rms_tlen_pp_rev;
static PyObject *__pyx_n_s_rms_tlen_rev;
static PyObject *__pyx_n_s_rootmean;
static PyObject *__pyx_n_s_round;
static PyObject *__pyx_n_s_rstart;
static PyObject *__pyx_n_s_rtid;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_sqsum;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_stat;
static PyObject *__pyx_n_s_stat_pileup;
static PyObject *__pyx_n_s_std;
static PyObject *__pyx_n_s_std_tlen;
static PyObject *__pyx_n_s_std_tlen_fwd;
static PyObject *__pyx_n_s_std_tlen_pp;
static PyObject *__pyx_n_s_std_tlen_pp_fwd;
static PyObject *__pyx_n_s_std_tlen_pp_rev;
static PyObject *__pyx_n_s_std_tlen_rev;
static PyObject *__pyx_n_s_string_types;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_n_s_sys_2;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_total;
static PyObject *__pyx_n_s_truncate;
static PyObject *__pyx_n_s_upper;
static PyObject *__pyx_n_s_version_info;
static PyObject *__pyx_n_s_window_offset;
static PyObject *__pyx_n_s_window_size;
static int __pyx_pf_10pysamstats_3opt_7CountPp___init__(struct __pyx_obj_10pysamstats_3opt_CountPp *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_7CountPp_2reset(struct __pyx_obj_10pysamstats_3opt_CountPp *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_8Coverage___init__(struct __pyx_obj_10pysamstats_3opt_Coverage *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_8Coverage_2reset(struct __pyx_obj_10pysamstats_3opt_Coverage *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_13CountPpStrand___init__(struct __pyx_obj_10pysamstats_3opt_CountPpStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_13CountPpStrand_2reset(struct __pyx_obj_10pysamstats_3opt_CountPpStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_14CoverageStrand___init__(struct __pyx_obj_10pysamstats_3opt_CoverageStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_14CoverageStrand_2reset(struct __pyx_obj_10pysamstats_3opt_CoverageStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_11CoverageExt___init__(struct __pyx_obj_10pysamstats_3opt_CoverageExt *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_11CoverageExt_2reset(struct __pyx_obj_10pysamstats_3opt_CoverageExt *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_11CountStrand___init__(struct __pyx_obj_10pysamstats_3opt_CountStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_11CountStrand_2reset(struct __pyx_obj_10pysamstats_3opt_CountStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_17CoverageExtStrand___init__(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_17CoverageExtStrand_2reset(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_9Variation___init__(struct __pyx_obj_10pysamstats_3opt_Variation *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_9Variation_2reset(struct __pyx_obj_10pysamstats_3opt_Variation *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_15VariationStrand___init__(struct __pyx_obj_10pysamstats_3opt_VariationStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_15VariationStrand_2reset(struct __pyx_obj_10pysamstats_3opt_VariationStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_10TlenHelper___init__(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_2reset(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_4variance(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_6std(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_8mean(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_10rms(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_4Tlen___init__(struct __pyx_obj_10pysamstats_3opt_Tlen *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_4Tlen_2reset(struct __pyx_obj_10pysamstats_3opt_Tlen *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_10TlenStrand___init__(struct __pyx_obj_10pysamstats_3opt_TlenStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10TlenStrand_2reset(struct __pyx_obj_10pysamstats_3opt_TlenStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_10MapqHelper___init__(struct __pyx_obj_10pysamstats_3opt_MapqHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10MapqHelper_2reset(struct __pyx_obj_10pysamstats_3opt_MapqHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10MapqHelper_4rms(struct __pyx_obj_10pysamstats_3opt_MapqHelper *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_4Mapq___init__(struct __pyx_obj_10pysamstats_3opt_Mapq *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_4Mapq_2reset(struct __pyx_obj_10pysamstats_3opt_Mapq *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_10MapqStrand___init__(struct __pyx_obj_10pysamstats_3opt_MapqStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10MapqStrand_2reset(struct __pyx_obj_10pysamstats_3opt_MapqStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_11BaseqHelper___init__(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_11BaseqHelper_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_11BaseqHelper_4rms(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_13BaseqPpHelper___init__(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_13BaseqPpHelper_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_5Baseq___init__(struct __pyx_obj_10pysamstats_3opt_Baseq *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_5Baseq_2reset(struct __pyx_obj_10pysamstats_3opt_Baseq *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_19BaseqStrandPpHelper___init__(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_19BaseqStrandPpHelper_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_11BaseqStrand___init__(struct __pyx_obj_10pysamstats_3opt_BaseqStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_11BaseqStrand_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_8BaseqExt___init__(struct __pyx_obj_10pysamstats_3opt_BaseqExt *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_8BaseqExt_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqExt *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_14BaseqExtStrand___init__(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_14BaseqExtStrand_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_10CoverageGC___init__(struct __pyx_obj_10pysamstats_3opt_CoverageGC *__pyx_v_self, PyObject *__pyx_v_window_size, PyObject *__pyx_v_window_offset); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_10CoverageGC_2reset(struct __pyx_obj_10pysamstats_3opt_CoverageGC *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_14CoverageBinned___init__(struct __pyx_obj_10pysamstats_3opt_CoverageBinned *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_17CoverageExtBinned___init__(struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_10MapqBinned___init__(struct __pyx_obj_10pysamstats_3opt_MapqBinned *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_15AlignmentBinned___init__(struct __pyx_obj_10pysamstats_3opt_AlignmentBinned *__pyx_v_self); /* proto */
static int __pyx_pf_10pysamstats_3opt_10TlenBinned___init__(struct __pyx_obj_10pysamstats_3opt_TlenBinned *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_iter_pileup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_pad, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_2iter_pileup_default(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_one_based, PyObject *__pyx_v_truncate, PyObject *__pyx_v_max_depth, int __pyx_v_min_mapq, int __pyx_v_min_baseq, int __pyx_v_no_del, int __pyx_v_no_dup); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_5stat_pileup(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_stat, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, int __pyx_v_one_based, int __pyx_v_min_mapq, int __pyx_v_min_baseq, int __pyx_v_no_del, int __pyx_v_no_dup); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_7iter_pileup_padded(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_9iter_pileup_padded_chrom(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_one_based, PyObject *__pyx_v_truncate, PyObject *__pyx_v_max_depth, PyObject *__pyx_v_min_mapq, PyObject *__pyx_v_min_baseq, PyObject *__pyx_v_no_del, PyObject *__pyx_v_no_dup); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_12get_refbase(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_pos); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_14iter_binned(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_window_size, PyObject *__pyx_v_window_offset, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_16iter_binned_chrom(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_10pysamstats_3opt_BinnedStat *__pyx_v_stat, struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_one_based, int __pyx_v_window_size, int __pyx_v_window_offset, int __pyx_v_min_mapq, int __pyx_v_no_dup); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_19normalise_coords(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_one_based); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_21rootmean(CYTHON_UNUSED PyObject *__pyx_self, uint64_t __pyx_v_sqsum, int __pyx_v_count); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_23mean(CYTHON_UNUSED PyObject *__pyx_self, int64_t __pyx_v_total, int __pyx_v_count); /* proto */
static PyObject *__pyx_pf_10pysamstats_3opt_25count_reads(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end); /* 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 PyObject *__pyx_tp_new_10pysamstats_3opt_PileupStat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CountPp(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_Coverage(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CountPpStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageExt(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CountStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageExtStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_Variation(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_VariationStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_TlenHelper(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_Tlen(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_TlenStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_MapqHelper(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_Mapq(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_MapqStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqHelper(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqPpHelper(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_Baseq(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqStrandPpHelper(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqExt(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqExtStrand(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageGC(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_BinnedStat(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageBinned(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageExtBinned(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_MapqBinned(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_AlignmentBinned(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt_TlenBinned(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_300;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_codeobj__6;
static PyObject *__pyx_codeobj__8;
static PyObject *__pyx_codeobj__10;
static PyObject *__pyx_codeobj__12;
static PyObject *__pyx_codeobj__14;
static PyObject *__pyx_codeobj__16;
static PyObject *__pyx_codeobj__18;
static PyObject *__pyx_codeobj__20;
static PyObject *__pyx_codeobj__22;
static PyObject *__pyx_codeobj__24;
static PyObject *__pyx_codeobj__26;
static PyObject *__pyx_codeobj__28;

/* "pysamstats/opt.pyx":76
 * cdef class PileupStat(object):
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 *         return dict()
 * 
 */

static PyObject *__pyx_f_10pysamstats_3opt_10PileupStat_rec(CYTHON_UNUSED struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":77
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 *         return dict()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":76
 * cdef class PileupStat(object):
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 *         return dict()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysamstats.opt.PileupStat.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":79
 *         return dict()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static void __pyx_f_10pysamstats_3opt_10PileupStat_recv(CYTHON_UNUSED struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_self, CYTHON_UNUSED bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("recv", 0);

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

/* "pysamstats/opt.pyx":93
 *         int all, pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_7CountPp___init__(struct __pyx_obj_10pysamstats_3opt_CountPp *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":94
 * 
 *     def __init__(self):
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 94, __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_ERR(0, 94, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":93
 *         int all, pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

  /* 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("pysamstats.opt.CountPp.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":96
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all = self.pp = 0
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_7CountPp_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_7CountPp_2reset[] = "CountPp.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_7CountPp_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_7CountPp_2reset(((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_7CountPp_2reset(struct __pyx_obj_10pysamstats_3opt_CountPp *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":97
 * 
 *     def reset(self):
 *         self.all = self.pp = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void incr(self, bint is_proper_pair):
 */
  __pyx_v_self->all = 0;
  __pyx_v_self->pp = 0;

  /* "pysamstats/opt.pyx":96
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all = self.pp = 0
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":99
 *         self.all = self.pp = 0
 * 
 *     cdef void incr(self, bint is_proper_pair):             # <<<<<<<<<<<<<<
 *         self.all += 1
 *         if is_proper_pair:
 */

static void __pyx_f_10pysamstats_3opt_7CountPp_incr(struct __pyx_obj_10pysamstats_3opt_CountPp *__pyx_v_self, int __pyx_v_is_proper_pair) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("incr", 0);

  /* "pysamstats/opt.pyx":100
 * 
 *     cdef void incr(self, bint is_proper_pair):
 *         self.all += 1             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.pp += 1
 */
  __pyx_v_self->all = (__pyx_v_self->all + 1);

  /* "pysamstats/opt.pyx":101
 *     cdef void incr(self, bint is_proper_pair):
 *         self.all += 1
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp += 1
 * 
 */
  __pyx_t_1 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":102
 *         self.all += 1
 *         if is_proper_pair:
 *             self.pp += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_self->pp = (__pyx_v_self->pp + 1);

    /* "pysamstats/opt.pyx":101
 *     cdef void incr(self, bint is_proper_pair):
 *         self.all += 1
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp += 1
 * 
 */
  }

  /* "pysamstats/opt.pyx":99
 *         self.all = self.pp = 0
 * 
 *     cdef void incr(self, bint is_proper_pair):             # <<<<<<<<<<<<<<
 *         self.all += 1
 *         if is_proper_pair:
 */

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

/* "pysamstats/opt.pyx":111
 *         CountPp reads
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads = CountPp()
 *         self.reset()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_8Coverage___init__(struct __pyx_obj_10pysamstats_3opt_Coverage *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":112
 * 
 *     def __init__(self):
 *         self.reads = CountPp()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->reads);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->reads));
  __pyx_v_self->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":113
 *     def __init__(self):
 *         self.reads = CountPp()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 113, __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_ERR(0, 113, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":111
 *         CountPp reads
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads = CountPp()
 *         self.reset()
 */

  /* 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("pysamstats.opt.Coverage.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":115
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_8Coverage_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_8Coverage_2reset[] = "Coverage.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_8Coverage_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_8Coverage_2reset(((struct __pyx_obj_10pysamstats_3opt_Coverage *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_8Coverage_2reset(struct __pyx_obj_10pysamstats_3opt_Coverage *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":116
 * 
 *     def reset(self):
 *         self.reads.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->reads), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 116, __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_ERR(0, 116, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":115
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 * 
 */

  /* 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_AddTraceback("pysamstats.opt.Coverage.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":118
 *         self.reads.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             bint is_proper_pair
 */

static void __pyx_f_10pysamstats_3opt_8Coverage_recv(struct __pyx_obj_10pysamstats_3opt_Coverage *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  int __pyx_v_is_proper_pair;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":123
 * 
 *         # convenience variables
 *         is_proper_pair = <bint>(read.b.core.flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_proper_pair = ((__pyx_v_read->b->core.flag & 2) != 0);

  /* "pysamstats/opt.pyx":126
 * 
 *         # do the counting
 *         self.reads.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->reads->__pyx_vtab)->incr(__pyx_v_self->reads, __pyx_v_is_proper_pair);

  /* "pysamstats/opt.pyx":118
 *         self.reads.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             bint is_proper_pair
 */

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

/* "pysamstats/opt.pyx":128
 *         self.reads.incr(is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_8Coverage_rec(struct __pyx_obj_10pysamstats_3opt_Coverage *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":131
 * 
 *         # make record
 *         rec = {'reads_all': self.reads.all,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.reads.pp}
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":132
 *         # make record
 *         rec = {'reads_all': self.reads.all,
 *                'reads_pp': self.reads.pp}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":135
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 135, __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_ERR(0, 135, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":137
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":128
 *         self.reads.incr(is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysamstats.opt.Coverage.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":150
 *         int all, pp, fwd, rev, pp_fwd, pp_rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_13CountPpStrand___init__(struct __pyx_obj_10pysamstats_3opt_CountPpStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":151
 * 
 *     def __init__(self):
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 151, __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_ERR(0, 151, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":150
 *         int all, pp, fwd, rev, pp_fwd, pp_rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

  /* 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("pysamstats.opt.CountPpStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":153
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all = self.fwd = self.rev = self.pp = self.pp_fwd = self.pp_rev = 0
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_13CountPpStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_13CountPpStrand_2reset[] = "CountPpStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_13CountPpStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_13CountPpStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_13CountPpStrand_2reset(struct __pyx_obj_10pysamstats_3opt_CountPpStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":154
 * 
 *     def reset(self):
 *         self.all = self.fwd = self.rev = self.pp = self.pp_fwd = self.pp_rev = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void incr(self, bint is_reverse, bint is_proper_pair):
 */
  __pyx_v_self->all = 0;
  __pyx_v_self->fwd = 0;
  __pyx_v_self->rev = 0;
  __pyx_v_self->pp = 0;
  __pyx_v_self->pp_fwd = 0;
  __pyx_v_self->pp_rev = 0;

  /* "pysamstats/opt.pyx":153
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all = self.fwd = self.rev = self.pp = self.pp_fwd = self.pp_rev = 0
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":156
 *         self.all = self.fwd = self.rev = self.pp = self.pp_fwd = self.pp_rev = 0
 * 
 *     cdef void incr(self, bint is_reverse, bint is_proper_pair):             # <<<<<<<<<<<<<<
 *         self.all += 1
 *         if is_reverse:
 */

static void __pyx_f_10pysamstats_3opt_13CountPpStrand_incr(struct __pyx_obj_10pysamstats_3opt_CountPpStrand *__pyx_v_self, int __pyx_v_is_reverse, int __pyx_v_is_proper_pair) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("incr", 0);

  /* "pysamstats/opt.pyx":157
 * 
 *     cdef void incr(self, bint is_reverse, bint is_proper_pair):
 *         self.all += 1             # <<<<<<<<<<<<<<
 *         if is_reverse:
 *             self.rev += 1
 */
  __pyx_v_self->all = (__pyx_v_self->all + 1);

  /* "pysamstats/opt.pyx":158
 *     cdef void incr(self, bint is_reverse, bint is_proper_pair):
 *         self.all += 1
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.rev += 1
 *             if is_proper_pair:
 */
  __pyx_t_1 = (__pyx_v_is_reverse != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":159
 *         self.all += 1
 *         if is_reverse:
 *             self.rev += 1             # <<<<<<<<<<<<<<
 *             if is_proper_pair:
 *                 self.pp += 1
 */
    __pyx_v_self->rev = (__pyx_v_self->rev + 1);

    /* "pysamstats/opt.pyx":160
 *         if is_reverse:
 *             self.rev += 1
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.pp += 1
 *                 self.pp_rev += 1
 */
    __pyx_t_1 = (__pyx_v_is_proper_pair != 0);
    if (__pyx_t_1) {

      /* "pysamstats/opt.pyx":161
 *             self.rev += 1
 *             if is_proper_pair:
 *                 self.pp += 1             # <<<<<<<<<<<<<<
 *                 self.pp_rev += 1
 *         else:
 */
      __pyx_v_self->pp = (__pyx_v_self->pp + 1);

      /* "pysamstats/opt.pyx":162
 *             if is_proper_pair:
 *                 self.pp += 1
 *                 self.pp_rev += 1             # <<<<<<<<<<<<<<
 *         else:
 *             self.fwd += 1
 */
      __pyx_v_self->pp_rev = (__pyx_v_self->pp_rev + 1);

      /* "pysamstats/opt.pyx":160
 *         if is_reverse:
 *             self.rev += 1
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.pp += 1
 *                 self.pp_rev += 1
 */
    }

    /* "pysamstats/opt.pyx":158
 *     cdef void incr(self, bint is_reverse, bint is_proper_pair):
 *         self.all += 1
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.rev += 1
 *             if is_proper_pair:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":164
 *                 self.pp_rev += 1
 *         else:
 *             self.fwd += 1             # <<<<<<<<<<<<<<
 *             if is_proper_pair:
 *                 self.pp += 1
 */
  /*else*/ {
    __pyx_v_self->fwd = (__pyx_v_self->fwd + 1);

    /* "pysamstats/opt.pyx":165
 *         else:
 *             self.fwd += 1
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.pp += 1
 *                 self.pp_fwd += 1
 */
    __pyx_t_1 = (__pyx_v_is_proper_pair != 0);
    if (__pyx_t_1) {

      /* "pysamstats/opt.pyx":166
 *             self.fwd += 1
 *             if is_proper_pair:
 *                 self.pp += 1             # <<<<<<<<<<<<<<
 *                 self.pp_fwd += 1
 * 
 */
      __pyx_v_self->pp = (__pyx_v_self->pp + 1);

      /* "pysamstats/opt.pyx":167
 *             if is_proper_pair:
 *                 self.pp += 1
 *                 self.pp_fwd += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_self->pp_fwd = (__pyx_v_self->pp_fwd + 1);

      /* "pysamstats/opt.pyx":165
 *         else:
 *             self.fwd += 1
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.pp += 1
 *                 self.pp_fwd += 1
 */
    }
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":156
 *         self.all = self.fwd = self.rev = self.pp = self.pp_fwd = self.pp_rev = 0
 * 
 *     cdef void incr(self, bint is_reverse, bint is_proper_pair):             # <<<<<<<<<<<<<<
 *         self.all += 1
 *         if is_reverse:
 */

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

/* "pysamstats/opt.pyx":176
 *         CountPpStrand reads
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads = CountPpStrand()
 *         self.reset()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_14CoverageStrand___init__(struct __pyx_obj_10pysamstats_3opt_CoverageStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":177
 * 
 *     def __init__(self):
 *         self.reads = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->reads);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->reads));
  __pyx_v_self->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":178
 *     def __init__(self):
 *         self.reads = CountPpStrand()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 178, __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_ERR(0, 178, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":176
 *         CountPpStrand reads
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads = CountPpStrand()
 *         self.reset()
 */

  /* 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("pysamstats.opt.CoverageStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":180
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_14CoverageStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_14CoverageStrand_2reset[] = "CoverageStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_14CoverageStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_14CoverageStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_CoverageStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_14CoverageStrand_2reset(struct __pyx_obj_10pysamstats_3opt_CoverageStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":181
 * 
 *     def reset(self):
 *         self.reads.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->reads), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 181, __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_ERR(0, 181, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":180
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 * 
 */

  /* 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_AddTraceback("pysamstats.opt.CoverageStrand.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":183
 *         self.reads.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_14CoverageStrand_recv(struct __pyx_obj_10pysamstats_3opt_CoverageStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int __pyx_v_is_reverse;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":190
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":191
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 * 
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":192
 *         flag = read.b.core.flag
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":195
 * 
 *         # do the counting
 *         self.reads.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->reads->__pyx_vtab)->incr(__pyx_v_self->reads, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

  /* "pysamstats/opt.pyx":183
 *         self.reads.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":197
 *         self.reads.incr(is_reverse, is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_14CoverageStrand_rec(struct __pyx_obj_10pysamstats_3opt_CoverageStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":200
 * 
 *         # make record
 *         rec = {'reads_all': self.reads.all,             # <<<<<<<<<<<<<<
 *                'reads_fwd': self.reads.fwd,
 *                'reads_rev': self.reads.rev,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":201
 *         # make record
 *         rec = {'reads_all': self.reads.all,
 *                'reads_fwd': self.reads.fwd,             # <<<<<<<<<<<<<<
 *                'reads_rev': self.reads.rev,
 *                'reads_pp': self.reads.pp,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":202
 *         rec = {'reads_all': self.reads.all,
 *                'reads_fwd': self.reads.fwd,
 *                'reads_rev': self.reads.rev,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.reads.pp,
 *                'reads_pp_fwd': self.reads.pp_fwd,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_rev, __pyx_t_2) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":203
 *                'reads_fwd': self.reads.fwd,
 *                'reads_rev': self.reads.rev,
 *                'reads_pp': self.reads.pp,             # <<<<<<<<<<<<<<
 *                'reads_pp_fwd': self.reads.pp_fwd,
 *                'reads_pp_rev': self.reads.pp_rev}
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":204
 *                'reads_rev': self.reads.rev,
 *                'reads_pp': self.reads.pp,
 *                'reads_pp_fwd': self.reads.pp_fwd,             # <<<<<<<<<<<<<<
 *                'reads_pp_rev': self.reads.pp_rev}
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp_fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":205
 *                'reads_pp': self.reads.pp,
 *                'reads_pp_fwd': self.reads.pp_fwd,
 *                'reads_pp_rev': self.reads.pp_rev}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp_rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":208
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 208, __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_ERR(0, 208, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":210
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":197
 *         self.reads.incr(is_reverse, is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysamstats.opt.CoverageStrand.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":231
 *         int reads_duplicate
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_11CoverageExt___init__(struct __pyx_obj_10pysamstats_3opt_CoverageExt *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":232
 * 
 *     def __init__(self):
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 232, __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_ERR(0, 232, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":231
 *         int reads_duplicate
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

  /* 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("pysamstats.opt.CoverageExt.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":234
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = 0
 *         self.reads_pp = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_11CoverageExt_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_11CoverageExt_2reset[] = "CoverageExt.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_11CoverageExt_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_11CoverageExt_2reset(((struct __pyx_obj_10pysamstats_3opt_CoverageExt *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_11CoverageExt_2reset(struct __pyx_obj_10pysamstats_3opt_CoverageExt *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":235
 * 
 *     def reset(self):
 *         self.reads_all = 0             # <<<<<<<<<<<<<<
 *         self.reads_pp = 0
 *         self.reads_mate_unmapped = 0
 */
  __pyx_v_self->reads_all = 0;

  /* "pysamstats/opt.pyx":236
 *     def reset(self):
 *         self.reads_all = 0
 *         self.reads_pp = 0             # <<<<<<<<<<<<<<
 *         self.reads_mate_unmapped = 0
 *         self.reads_mate_other_chr = 0
 */
  __pyx_v_self->reads_pp = 0;

  /* "pysamstats/opt.pyx":237
 *         self.reads_all = 0
 *         self.reads_pp = 0
 *         self.reads_mate_unmapped = 0             # <<<<<<<<<<<<<<
 *         self.reads_mate_other_chr = 0
 *         self.reads_mate_same_strand = 0
 */
  __pyx_v_self->reads_mate_unmapped = 0;

  /* "pysamstats/opt.pyx":238
 *         self.reads_pp = 0
 *         self.reads_mate_unmapped = 0
 *         self.reads_mate_other_chr = 0             # <<<<<<<<<<<<<<
 *         self.reads_mate_same_strand = 0
 *         self.reads_faceaway = 0
 */
  __pyx_v_self->reads_mate_other_chr = 0;

  /* "pysamstats/opt.pyx":239
 *         self.reads_mate_unmapped = 0
 *         self.reads_mate_other_chr = 0
 *         self.reads_mate_same_strand = 0             # <<<<<<<<<<<<<<
 *         self.reads_faceaway = 0
 *         self.reads_softclipped = 0
 */
  __pyx_v_self->reads_mate_same_strand = 0;

  /* "pysamstats/opt.pyx":240
 *         self.reads_mate_other_chr = 0
 *         self.reads_mate_same_strand = 0
 *         self.reads_faceaway = 0             # <<<<<<<<<<<<<<
 *         self.reads_softclipped = 0
 *         self.reads_duplicate = 0
 */
  __pyx_v_self->reads_faceaway = 0;

  /* "pysamstats/opt.pyx":241
 *         self.reads_mate_same_strand = 0
 *         self.reads_faceaway = 0
 *         self.reads_softclipped = 0             # <<<<<<<<<<<<<<
 *         self.reads_duplicate = 0
 * 
 */
  __pyx_v_self->reads_softclipped = 0;

  /* "pysamstats/opt.pyx":242
 *         self.reads_faceaway = 0
 *         self.reads_softclipped = 0
 *         self.reads_duplicate = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_v_self->reads_duplicate = 0;

  /* "pysamstats/opt.pyx":234
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = 0
 *         self.reads_pp = 0
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":244
 *         self.reads_duplicate = 0
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_11CoverageExt_recv(struct __pyx_obj_10pysamstats_3opt_CoverageExt *__pyx_v_self, bam_pileup1_t *__pyx_v_read, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int __pyx_v_is_reverse;
  int __pyx_v_is_duplicate;
  int __pyx_v_mate_is_reverse;
  int __pyx_v_tlen;
  int __pyx_v_mate_is_unmapped;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":255
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":256
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_duplicate = <bint>(flag & BAM_FDUP)
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":257
 *         flag = read.b.core.flag
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         is_duplicate = <bint>(flag & BAM_FDUP)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":258
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_duplicate = <bint>(flag & BAM_FDUP)             # <<<<<<<<<<<<<<
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 */
  __pyx_v_is_duplicate = ((__pyx_v_flag & 0x400) != 0);

  /* "pysamstats/opt.pyx":259
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_duplicate = <bint>(flag & BAM_FDUP)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)             # <<<<<<<<<<<<<<
 *         mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 *         tlen = read.b.core.isize
 */
  __pyx_v_mate_is_unmapped = ((__pyx_v_flag & 8) != 0);

  /* "pysamstats/opt.pyx":260
 *         is_duplicate = <bint>(flag & BAM_FDUP)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_is_reverse = <bint>(flag & BAM_FMREVERSE)             # <<<<<<<<<<<<<<
 *         tlen = read.b.core.isize
 * 
 */
  __pyx_v_mate_is_reverse = ((__pyx_v_flag & 32) != 0);

  /* "pysamstats/opt.pyx":261
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 *         tlen = read.b.core.isize             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_t_2 = __pyx_v_read->b->core.isize;
  __pyx_v_tlen = __pyx_t_2;

  /* "pysamstats/opt.pyx":264
 * 
 *         # do the counting
 *         self.reads_all += 1             # <<<<<<<<<<<<<<
 *         if is_duplicate:
 *             self.reads_duplicate += 1
 */
  __pyx_v_self->reads_all = (__pyx_v_self->reads_all + 1);

  /* "pysamstats/opt.pyx":265
 *         # do the counting
 *         self.reads_all += 1
 *         if is_duplicate:             # <<<<<<<<<<<<<<
 *             self.reads_duplicate += 1
 *         if is_proper_pair:
 */
  __pyx_t_3 = (__pyx_v_is_duplicate != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":266
 *         self.reads_all += 1
 *         if is_duplicate:
 *             self.reads_duplicate += 1             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.reads_pp += 1
 */
    __pyx_v_self->reads_duplicate = (__pyx_v_self->reads_duplicate + 1);

    /* "pysamstats/opt.pyx":265
 *         # do the counting
 *         self.reads_all += 1
 *         if is_duplicate:             # <<<<<<<<<<<<<<
 *             self.reads_duplicate += 1
 *         if is_proper_pair:
 */
  }

  /* "pysamstats/opt.pyx":267
 *         if is_duplicate:
 *             self.reads_duplicate += 1
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.reads_pp += 1
 *         if mate_is_unmapped:
 */
  __pyx_t_3 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":268
 *             self.reads_duplicate += 1
 *         if is_proper_pair:
 *             self.reads_pp += 1             # <<<<<<<<<<<<<<
 *         if mate_is_unmapped:
 *             self.reads_mate_unmapped += 1
 */
    __pyx_v_self->reads_pp = (__pyx_v_self->reads_pp + 1);

    /* "pysamstats/opt.pyx":267
 *         if is_duplicate:
 *             self.reads_duplicate += 1
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.reads_pp += 1
 *         if mate_is_unmapped:
 */
  }

  /* "pysamstats/opt.pyx":269
 *         if is_proper_pair:
 *             self.reads_pp += 1
 *         if mate_is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_mate_unmapped += 1
 *         elif col.tid != read.b.core.mtid:
 */
  __pyx_t_3 = (__pyx_v_mate_is_unmapped != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":270
 *             self.reads_pp += 1
 *         if mate_is_unmapped:
 *             self.reads_mate_unmapped += 1             # <<<<<<<<<<<<<<
 *         elif col.tid != read.b.core.mtid:
 *             self.reads_mate_other_chr += 1
 */
    __pyx_v_self->reads_mate_unmapped = (__pyx_v_self->reads_mate_unmapped + 1);

    /* "pysamstats/opt.pyx":269
 *         if is_proper_pair:
 *             self.reads_pp += 1
 *         if mate_is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_mate_unmapped += 1
 *         elif col.tid != read.b.core.mtid:
 */
    goto __pyx_L5;
  }

  /* "pysamstats/opt.pyx":271
 *         if mate_is_unmapped:
 *             self.reads_mate_unmapped += 1
 *         elif col.tid != read.b.core.mtid:             # <<<<<<<<<<<<<<
 *             self.reads_mate_other_chr += 1
 *         elif (is_reverse and mate_is_reverse) or (not is_reverse and not mate_is_reverse):
 */
  __pyx_t_3 = ((__pyx_v_col->tid != __pyx_v_read->b->core.mtid) != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":272
 *             self.reads_mate_unmapped += 1
 *         elif col.tid != read.b.core.mtid:
 *             self.reads_mate_other_chr += 1             # <<<<<<<<<<<<<<
 *         elif (is_reverse and mate_is_reverse) or (not is_reverse and not mate_is_reverse):
 *             self.reads_mate_same_strand += 1
 */
    __pyx_v_self->reads_mate_other_chr = (__pyx_v_self->reads_mate_other_chr + 1);

    /* "pysamstats/opt.pyx":271
 *         if mate_is_unmapped:
 *             self.reads_mate_unmapped += 1
 *         elif col.tid != read.b.core.mtid:             # <<<<<<<<<<<<<<
 *             self.reads_mate_other_chr += 1
 *         elif (is_reverse and mate_is_reverse) or (not is_reverse and not mate_is_reverse):
 */
    goto __pyx_L5;
  }

  /* "pysamstats/opt.pyx":273
 *         elif col.tid != read.b.core.mtid:
 *             self.reads_mate_other_chr += 1
 *         elif (is_reverse and mate_is_reverse) or (not is_reverse and not mate_is_reverse):             # <<<<<<<<<<<<<<
 *             self.reads_mate_same_strand += 1
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 */
  __pyx_t_4 = (__pyx_v_is_reverse != 0);
  if (!__pyx_t_4) {
    goto __pyx_L7_next_or;
  } else {
  }
  __pyx_t_4 = (__pyx_v_mate_is_reverse != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_L7_next_or:;
  __pyx_t_4 = ((!(__pyx_v_is_reverse != 0)) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_4 = ((!(__pyx_v_mate_is_reverse != 0)) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":274
 *             self.reads_mate_other_chr += 1
 *         elif (is_reverse and mate_is_reverse) or (not is_reverse and not mate_is_reverse):
 *             self.reads_mate_same_strand += 1             # <<<<<<<<<<<<<<
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *             self.reads_faceaway += 1
 */
    __pyx_v_self->reads_mate_same_strand = (__pyx_v_self->reads_mate_same_strand + 1);

    /* "pysamstats/opt.pyx":273
 *         elif col.tid != read.b.core.mtid:
 *             self.reads_mate_other_chr += 1
 *         elif (is_reverse and mate_is_reverse) or (not is_reverse and not mate_is_reverse):             # <<<<<<<<<<<<<<
 *             self.reads_mate_same_strand += 1
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 */
    goto __pyx_L5;
  }

  /* "pysamstats/opt.pyx":275
 *         elif (is_reverse and mate_is_reverse) or (not is_reverse and not mate_is_reverse):
 *             self.reads_mate_same_strand += 1
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):             # <<<<<<<<<<<<<<
 *             self.reads_faceaway += 1
 *         if is_softclipped(read.b):
 */
  __pyx_t_4 = (__pyx_v_is_reverse != 0);
  if (!__pyx_t_4) {
    goto __pyx_L11_next_or;
  } else {
  }
  __pyx_t_4 = ((__pyx_v_tlen > 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_L11_next_or:;
  __pyx_t_4 = ((!(__pyx_v_is_reverse != 0)) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_tlen < 0) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":276
 *             self.reads_mate_same_strand += 1
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *             self.reads_faceaway += 1             # <<<<<<<<<<<<<<
 *         if is_softclipped(read.b):
 *             self.reads_softclipped += 1
 */
    __pyx_v_self->reads_faceaway = (__pyx_v_self->reads_faceaway + 1);

    /* "pysamstats/opt.pyx":275
 *         elif (is_reverse and mate_is_reverse) or (not is_reverse and not mate_is_reverse):
 *             self.reads_mate_same_strand += 1
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):             # <<<<<<<<<<<<<<
 *             self.reads_faceaway += 1
 *         if is_softclipped(read.b):
 */
  }
  __pyx_L5:;

  /* "pysamstats/opt.pyx":277
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *             self.reads_faceaway += 1
 *         if is_softclipped(read.b):             # <<<<<<<<<<<<<<
 *             self.reads_softclipped += 1
 * 
 */
  __pyx_t_3 = (__pyx_f_10pysamstats_3opt_is_softclipped(__pyx_v_read->b) != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":278
 *             self.reads_faceaway += 1
 *         if is_softclipped(read.b):
 *             self.reads_softclipped += 1             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    __pyx_v_self->reads_softclipped = (__pyx_v_self->reads_softclipped + 1);

    /* "pysamstats/opt.pyx":277
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *             self.reads_faceaway += 1
 *         if is_softclipped(read.b):             # <<<<<<<<<<<<<<
 *             self.reads_softclipped += 1
 * 
 */
  }

  /* "pysamstats/opt.pyx":244
 *         self.reads_duplicate = 0
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":280
 *             self.reads_softclipped += 1
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_11CoverageExt_rec(struct __pyx_obj_10pysamstats_3opt_CoverageExt *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":283
 * 
 *         # make record
 *         rec = {'reads_all': self.reads_all,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.reads_pp,
 *                'reads_mate_unmapped': self.reads_mate_unmapped,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":284
 *         # make record
 *         rec = {'reads_all': self.reads_all,
 *                'reads_pp': self.reads_pp,             # <<<<<<<<<<<<<<
 *                'reads_mate_unmapped': self.reads_mate_unmapped,
 *                'reads_mate_other_chr': self.reads_mate_other_chr,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_pp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":285
 *         rec = {'reads_all': self.reads_all,
 *                'reads_pp': self.reads_pp,
 *                'reads_mate_unmapped': self.reads_mate_unmapped,             # <<<<<<<<<<<<<<
 *                'reads_mate_other_chr': self.reads_mate_other_chr,
 *                'reads_mate_same_strand': self.reads_mate_same_strand,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_mate_unmapped); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_unmapped, __pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":286
 *                'reads_pp': self.reads_pp,
 *                'reads_mate_unmapped': self.reads_mate_unmapped,
 *                'reads_mate_other_chr': self.reads_mate_other_chr,             # <<<<<<<<<<<<<<
 *                'reads_mate_same_strand': self.reads_mate_same_strand,
 *                'reads_faceaway': self.reads_faceaway,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_mate_other_chr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_other_chr, __pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":287
 *                'reads_mate_unmapped': self.reads_mate_unmapped,
 *                'reads_mate_other_chr': self.reads_mate_other_chr,
 *                'reads_mate_same_strand': self.reads_mate_same_strand,             # <<<<<<<<<<<<<<
 *                'reads_faceaway': self.reads_faceaway,
 *                'reads_softclipped': self.reads_softclipped,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_mate_same_strand); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_same_strand, __pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":288
 *                'reads_mate_other_chr': self.reads_mate_other_chr,
 *                'reads_mate_same_strand': self.reads_mate_same_strand,
 *                'reads_faceaway': self.reads_faceaway,             # <<<<<<<<<<<<<<
 *                'reads_softclipped': self.reads_softclipped,
 *                'reads_duplicate': self.reads_duplicate}
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_faceaway); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_faceaway, __pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":289
 *                'reads_mate_same_strand': self.reads_mate_same_strand,
 *                'reads_faceaway': self.reads_faceaway,
 *                'reads_softclipped': self.reads_softclipped,             # <<<<<<<<<<<<<<
 *                'reads_duplicate': self.reads_duplicate}
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_softclipped); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_softclipped, __pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":290
 *                'reads_faceaway': self.reads_faceaway,
 *                'reads_softclipped': self.reads_softclipped,
 *                'reads_duplicate': self.reads_duplicate}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_duplicate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_duplicate, __pyx_t_2) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":293
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 293, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 293, __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_ERR(0, 293, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":295
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":280
 *             self.reads_softclipped += 1
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysamstats.opt.CoverageExt.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":308
 *         int all, fwd, rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_11CountStrand___init__(struct __pyx_obj_10pysamstats_3opt_CountStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":309
 * 
 *     def __init__(self):
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 309, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 309, __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_ERR(0, 309, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":308
 *         int all, fwd, rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

  /* 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("pysamstats.opt.CountStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":311
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all = self.fwd = self.rev = 0
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_11CountStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_11CountStrand_2reset[] = "CountStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_11CountStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_11CountStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_11CountStrand_2reset(struct __pyx_obj_10pysamstats_3opt_CountStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":312
 * 
 *     def reset(self):
 *         self.all = self.fwd = self.rev = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void incr(self, bint is_reverse):
 */
  __pyx_v_self->all = 0;
  __pyx_v_self->fwd = 0;
  __pyx_v_self->rev = 0;

  /* "pysamstats/opt.pyx":311
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all = self.fwd = self.rev = 0
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":314
 *         self.all = self.fwd = self.rev = 0
 * 
 *     cdef void incr(self, bint is_reverse):             # <<<<<<<<<<<<<<
 *         self.all += 1
 *         if is_reverse:
 */

static void __pyx_f_10pysamstats_3opt_11CountStrand_incr(struct __pyx_obj_10pysamstats_3opt_CountStrand *__pyx_v_self, int __pyx_v_is_reverse) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("incr", 0);

  /* "pysamstats/opt.pyx":315
 * 
 *     cdef void incr(self, bint is_reverse):
 *         self.all += 1             # <<<<<<<<<<<<<<
 *         if is_reverse:
 *             self.rev += 1
 */
  __pyx_v_self->all = (__pyx_v_self->all + 1);

  /* "pysamstats/opt.pyx":316
 *     cdef void incr(self, bint is_reverse):
 *         self.all += 1
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.rev += 1
 *         else:
 */
  __pyx_t_1 = (__pyx_v_is_reverse != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":317
 *         self.all += 1
 *         if is_reverse:
 *             self.rev += 1             # <<<<<<<<<<<<<<
 *         else:
 *             self.fwd += 1
 */
    __pyx_v_self->rev = (__pyx_v_self->rev + 1);

    /* "pysamstats/opt.pyx":316
 *     cdef void incr(self, bint is_reverse):
 *         self.all += 1
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.rev += 1
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":319
 *             self.rev += 1
 *         else:
 *             self.fwd += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_v_self->fwd = (__pyx_v_self->fwd + 1);
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":314
 *         self.all = self.fwd = self.rev = 0
 * 
 *     cdef void incr(self, bint is_reverse):             # <<<<<<<<<<<<<<
 *         self.all += 1
 *         if is_reverse:
 */

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

/* "pysamstats/opt.pyx":335
 *         CountStrand duplicate
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = CountStrand()
 *         self.pp = CountStrand()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_17CoverageExtStrand___init__(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":336
 * 
 *     def __init__(self):
 *         self.all = CountStrand()             # <<<<<<<<<<<<<<
 *         self.pp = CountStrand()
 *         self.mate_unmapped = CountStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->all);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->all));
  __pyx_v_self->all = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":337
 *     def __init__(self):
 *         self.all = CountStrand()
 *         self.pp = CountStrand()             # <<<<<<<<<<<<<<
 *         self.mate_unmapped = CountStrand()
 *         self.mate_other_chr = CountStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp));
  __pyx_v_self->pp = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":338
 *         self.all = CountStrand()
 *         self.pp = CountStrand()
 *         self.mate_unmapped = CountStrand()             # <<<<<<<<<<<<<<
 *         self.mate_other_chr = CountStrand()
 *         self.same_strand = CountStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mate_unmapped);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mate_unmapped));
  __pyx_v_self->mate_unmapped = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":339
 *         self.pp = CountStrand()
 *         self.mate_unmapped = CountStrand()
 *         self.mate_other_chr = CountStrand()             # <<<<<<<<<<<<<<
 *         self.same_strand = CountStrand()
 *         self.faceaway = CountStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mate_other_chr);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mate_other_chr));
  __pyx_v_self->mate_other_chr = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":340
 *         self.mate_unmapped = CountStrand()
 *         self.mate_other_chr = CountStrand()
 *         self.same_strand = CountStrand()             # <<<<<<<<<<<<<<
 *         self.faceaway = CountStrand()
 *         self.softclipped = CountStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->same_strand);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->same_strand));
  __pyx_v_self->same_strand = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":341
 *         self.mate_other_chr = CountStrand()
 *         self.same_strand = CountStrand()
 *         self.faceaway = CountStrand()             # <<<<<<<<<<<<<<
 *         self.softclipped = CountStrand()
 *         self.duplicate = CountStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->faceaway);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->faceaway));
  __pyx_v_self->faceaway = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":342
 *         self.same_strand = CountStrand()
 *         self.faceaway = CountStrand()
 *         self.softclipped = CountStrand()             # <<<<<<<<<<<<<<
 *         self.duplicate = CountStrand()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->softclipped);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->softclipped));
  __pyx_v_self->softclipped = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":343
 *         self.faceaway = CountStrand()
 *         self.softclipped = CountStrand()
 *         self.duplicate = CountStrand()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->duplicate);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->duplicate));
  __pyx_v_self->duplicate = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":344
 *         self.softclipped = CountStrand()
 *         self.duplicate = CountStrand()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 344, __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_ERR(0, 344, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":335
 *         CountStrand duplicate
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = CountStrand()
 *         self.pp = CountStrand()
 */

  /* 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("pysamstats.opt.CoverageExtStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":346
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.pp.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_17CoverageExtStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_17CoverageExtStrand_2reset[] = "CoverageExtStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_17CoverageExtStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_17CoverageExtStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_17CoverageExtStrand_2reset(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":347
 * 
 *     def reset(self):
 *         self.all.reset()             # <<<<<<<<<<<<<<
 *         self.pp.reset()
 *         self.mate_unmapped.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 347, __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_ERR(0, 347, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":348
 *     def reset(self):
 *         self.all.reset()
 *         self.pp.reset()             # <<<<<<<<<<<<<<
 *         self.mate_unmapped.reset()
 *         self.mate_other_chr.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 348, __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_ERR(0, 348, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":349
 *         self.all.reset()
 *         self.pp.reset()
 *         self.mate_unmapped.reset()             # <<<<<<<<<<<<<<
 *         self.mate_other_chr.reset()
 *         self.same_strand.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mate_unmapped), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 349, __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_ERR(0, 349, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":350
 *         self.pp.reset()
 *         self.mate_unmapped.reset()
 *         self.mate_other_chr.reset()             # <<<<<<<<<<<<<<
 *         self.same_strand.reset()
 *         self.faceaway.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mate_other_chr), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 350, __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_ERR(0, 350, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":351
 *         self.mate_unmapped.reset()
 *         self.mate_other_chr.reset()
 *         self.same_strand.reset()             # <<<<<<<<<<<<<<
 *         self.faceaway.reset()
 *         self.softclipped.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->same_strand), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 351, __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_ERR(0, 351, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":352
 *         self.mate_other_chr.reset()
 *         self.same_strand.reset()
 *         self.faceaway.reset()             # <<<<<<<<<<<<<<
 *         self.softclipped.reset()
 *         self.duplicate.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->faceaway), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 352, __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_ERR(0, 352, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":353
 *         self.same_strand.reset()
 *         self.faceaway.reset()
 *         self.softclipped.reset()             # <<<<<<<<<<<<<<
 *         self.duplicate.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->softclipped), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 353, __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_ERR(0, 353, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":354
 *         self.faceaway.reset()
 *         self.softclipped.reset()
 *         self.duplicate.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->duplicate), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 354, __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_ERR(0, 354, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":346
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.pp.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.CoverageExtStrand.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":356
 *         self.duplicate.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_17CoverageExtStrand_recv(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int __pyx_v_is_reverse;
  int __pyx_v_is_duplicate;
  int __pyx_v_mate_is_reverse;
  int __pyx_v_tlen;
  int __pyx_v_mate_is_unmapped;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":367
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":368
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_duplicate = <bint>(flag & BAM_FDUP)
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":369
 *         flag = read.b.core.flag
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         is_duplicate = <bint>(flag & BAM_FDUP)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":370
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_duplicate = <bint>(flag & BAM_FDUP)             # <<<<<<<<<<<<<<
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 */
  __pyx_v_is_duplicate = ((__pyx_v_flag & 0x400) != 0);

  /* "pysamstats/opt.pyx":371
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_duplicate = <bint>(flag & BAM_FDUP)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)             # <<<<<<<<<<<<<<
 *         mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 *         tlen = read.b.core.isize
 */
  __pyx_v_mate_is_unmapped = ((__pyx_v_flag & 8) != 0);

  /* "pysamstats/opt.pyx":372
 *         is_duplicate = <bint>(flag & BAM_FDUP)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_is_reverse = <bint>(flag & BAM_FMREVERSE)             # <<<<<<<<<<<<<<
 *         tlen = read.b.core.isize
 * 
 */
  __pyx_v_mate_is_reverse = ((__pyx_v_flag & 32) != 0);

  /* "pysamstats/opt.pyx":373
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 *         tlen = read.b.core.isize             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_t_2 = __pyx_v_read->b->core.isize;
  __pyx_v_tlen = __pyx_t_2;

  /* "pysamstats/opt.pyx":376
 * 
 *         # do the counting
 *         self.all.incr(is_reverse)             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.pp.incr(is_reverse)
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->all->__pyx_vtab)->incr(__pyx_v_self->all, __pyx_v_is_reverse);

  /* "pysamstats/opt.pyx":377
 *         # do the counting
 *         self.all.incr(is_reverse)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.incr(is_reverse)
 *         if mate_is_unmapped:
 */
  __pyx_t_3 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":378
 *         self.all.incr(is_reverse)
 *         if is_proper_pair:
 *             self.pp.incr(is_reverse)             # <<<<<<<<<<<<<<
 *         if mate_is_unmapped:
 *             self.mate_unmapped.incr(is_reverse)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->pp->__pyx_vtab)->incr(__pyx_v_self->pp, __pyx_v_is_reverse);

    /* "pysamstats/opt.pyx":377
 *         # do the counting
 *         self.all.incr(is_reverse)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.incr(is_reverse)
 *         if mate_is_unmapped:
 */
  }

  /* "pysamstats/opt.pyx":379
 *         if is_proper_pair:
 *             self.pp.incr(is_reverse)
 *         if mate_is_unmapped:             # <<<<<<<<<<<<<<
 *             self.mate_unmapped.incr(is_reverse)
 *         elif col.tid != read.b.core.mtid:
 */
  __pyx_t_3 = (__pyx_v_mate_is_unmapped != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":380
 *             self.pp.incr(is_reverse)
 *         if mate_is_unmapped:
 *             self.mate_unmapped.incr(is_reverse)             # <<<<<<<<<<<<<<
 *         elif col.tid != read.b.core.mtid:
 *             self.mate_other_chr.incr(is_reverse)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->mate_unmapped->__pyx_vtab)->incr(__pyx_v_self->mate_unmapped, __pyx_v_is_reverse);

    /* "pysamstats/opt.pyx":379
 *         if is_proper_pair:
 *             self.pp.incr(is_reverse)
 *         if mate_is_unmapped:             # <<<<<<<<<<<<<<
 *             self.mate_unmapped.incr(is_reverse)
 *         elif col.tid != read.b.core.mtid:
 */
    goto __pyx_L4;
  }

  /* "pysamstats/opt.pyx":381
 *         if mate_is_unmapped:
 *             self.mate_unmapped.incr(is_reverse)
 *         elif col.tid != read.b.core.mtid:             # <<<<<<<<<<<<<<
 *             self.mate_other_chr.incr(is_reverse)
 *         elif is_reverse and mate_is_reverse:
 */
  __pyx_t_3 = ((__pyx_v_col->tid != __pyx_v_read->b->core.mtid) != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":382
 *             self.mate_unmapped.incr(is_reverse)
 *         elif col.tid != read.b.core.mtid:
 *             self.mate_other_chr.incr(is_reverse)             # <<<<<<<<<<<<<<
 *         elif is_reverse and mate_is_reverse:
 *             self.same_strand.incr(is_reverse)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->mate_other_chr->__pyx_vtab)->incr(__pyx_v_self->mate_other_chr, __pyx_v_is_reverse);

    /* "pysamstats/opt.pyx":381
 *         if mate_is_unmapped:
 *             self.mate_unmapped.incr(is_reverse)
 *         elif col.tid != read.b.core.mtid:             # <<<<<<<<<<<<<<
 *             self.mate_other_chr.incr(is_reverse)
 *         elif is_reverse and mate_is_reverse:
 */
    goto __pyx_L4;
  }

  /* "pysamstats/opt.pyx":383
 *         elif col.tid != read.b.core.mtid:
 *             self.mate_other_chr.incr(is_reverse)
 *         elif is_reverse and mate_is_reverse:             # <<<<<<<<<<<<<<
 *             self.same_strand.incr(is_reverse)
 *         elif not is_reverse and not mate_is_reverse:
 */
  __pyx_t_4 = (__pyx_v_is_reverse != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = (__pyx_v_mate_is_reverse != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":384
 *             self.mate_other_chr.incr(is_reverse)
 *         elif is_reverse and mate_is_reverse:
 *             self.same_strand.incr(is_reverse)             # <<<<<<<<<<<<<<
 *         elif not is_reverse and not mate_is_reverse:
 *             self.same_strand.incr(is_reverse)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->same_strand->__pyx_vtab)->incr(__pyx_v_self->same_strand, __pyx_v_is_reverse);

    /* "pysamstats/opt.pyx":383
 *         elif col.tid != read.b.core.mtid:
 *             self.mate_other_chr.incr(is_reverse)
 *         elif is_reverse and mate_is_reverse:             # <<<<<<<<<<<<<<
 *             self.same_strand.incr(is_reverse)
 *         elif not is_reverse and not mate_is_reverse:
 */
    goto __pyx_L4;
  }

  /* "pysamstats/opt.pyx":385
 *         elif is_reverse and mate_is_reverse:
 *             self.same_strand.incr(is_reverse)
 *         elif not is_reverse and not mate_is_reverse:             # <<<<<<<<<<<<<<
 *             self.same_strand.incr(is_reverse)
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 */
  __pyx_t_4 = ((!(__pyx_v_is_reverse != 0)) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_4 = ((!(__pyx_v_mate_is_reverse != 0)) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":386
 *             self.same_strand.incr(is_reverse)
 *         elif not is_reverse and not mate_is_reverse:
 *             self.same_strand.incr(is_reverse)             # <<<<<<<<<<<<<<
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *             self.faceaway.incr(is_reverse)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->same_strand->__pyx_vtab)->incr(__pyx_v_self->same_strand, __pyx_v_is_reverse);

    /* "pysamstats/opt.pyx":385
 *         elif is_reverse and mate_is_reverse:
 *             self.same_strand.incr(is_reverse)
 *         elif not is_reverse and not mate_is_reverse:             # <<<<<<<<<<<<<<
 *             self.same_strand.incr(is_reverse)
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 */
    goto __pyx_L4;
  }

  /* "pysamstats/opt.pyx":387
 *         elif not is_reverse and not mate_is_reverse:
 *             self.same_strand.incr(is_reverse)
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):             # <<<<<<<<<<<<<<
 *             self.faceaway.incr(is_reverse)
 *         if is_softclipped(read.b):
 */
  __pyx_t_4 = (__pyx_v_is_reverse != 0);
  if (!__pyx_t_4) {
    goto __pyx_L10_next_or;
  } else {
  }
  __pyx_t_4 = ((__pyx_v_tlen > 0) != 0);
  if (!__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_L10_next_or:;
  __pyx_t_4 = ((!(__pyx_v_is_reverse != 0)) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_4 = ((__pyx_v_tlen < 0) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L9_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":388
 *             self.same_strand.incr(is_reverse)
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *             self.faceaway.incr(is_reverse)             # <<<<<<<<<<<<<<
 *         if is_softclipped(read.b):
 *             self.softclipped.incr(is_reverse)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->faceaway->__pyx_vtab)->incr(__pyx_v_self->faceaway, __pyx_v_is_reverse);

    /* "pysamstats/opt.pyx":387
 *         elif not is_reverse and not mate_is_reverse:
 *             self.same_strand.incr(is_reverse)
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):             # <<<<<<<<<<<<<<
 *             self.faceaway.incr(is_reverse)
 *         if is_softclipped(read.b):
 */
  }
  __pyx_L4:;

  /* "pysamstats/opt.pyx":389
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *             self.faceaway.incr(is_reverse)
 *         if is_softclipped(read.b):             # <<<<<<<<<<<<<<
 *             self.softclipped.incr(is_reverse)
 *         if is_duplicate:
 */
  __pyx_t_3 = (__pyx_f_10pysamstats_3opt_is_softclipped(__pyx_v_read->b) != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":390
 *             self.faceaway.incr(is_reverse)
 *         if is_softclipped(read.b):
 *             self.softclipped.incr(is_reverse)             # <<<<<<<<<<<<<<
 *         if is_duplicate:
 *             self.duplicate.incr(is_reverse)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->softclipped->__pyx_vtab)->incr(__pyx_v_self->softclipped, __pyx_v_is_reverse);

    /* "pysamstats/opt.pyx":389
 *         elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *             self.faceaway.incr(is_reverse)
 *         if is_softclipped(read.b):             # <<<<<<<<<<<<<<
 *             self.softclipped.incr(is_reverse)
 *         if is_duplicate:
 */
  }

  /* "pysamstats/opt.pyx":391
 *         if is_softclipped(read.b):
 *             self.softclipped.incr(is_reverse)
 *         if is_duplicate:             # <<<<<<<<<<<<<<
 *             self.duplicate.incr(is_reverse)
 * 
 */
  __pyx_t_3 = (__pyx_v_is_duplicate != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":392
 *             self.softclipped.incr(is_reverse)
 *         if is_duplicate:
 *             self.duplicate.incr(is_reverse)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_CountStrand *)__pyx_v_self->duplicate->__pyx_vtab)->incr(__pyx_v_self->duplicate, __pyx_v_is_reverse);

    /* "pysamstats/opt.pyx":391
 *         if is_softclipped(read.b):
 *             self.softclipped.incr(is_reverse)
 *         if is_duplicate:             # <<<<<<<<<<<<<<
 *             self.duplicate.incr(is_reverse)
 * 
 */
  }

  /* "pysamstats/opt.pyx":356
 *         self.duplicate.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":394
 *             self.duplicate.incr(is_reverse)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_17CoverageExtStrand_rec(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":397
 * 
 *         # make record
 *         rec = {'reads_all': self.all.all,             # <<<<<<<<<<<<<<
 *                'reads_fwd': self.all.fwd,
 *                'reads_rev': self.all.rev,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->all->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":398
 *         # make record
 *         rec = {'reads_all': self.all.all,
 *                'reads_fwd': self.all.fwd,             # <<<<<<<<<<<<<<
 *                'reads_rev': self.all.rev,
 *                'reads_pp': self.pp.all,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->all->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":399
 *         rec = {'reads_all': self.all.all,
 *                'reads_fwd': self.all.fwd,
 *                'reads_rev': self.all.rev,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.pp.all,
 *                'reads_pp_fwd': self.pp.fwd,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->all->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_rev, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":400
 *                'reads_fwd': self.all.fwd,
 *                'reads_rev': self.all.rev,
 *                'reads_pp': self.pp.all,             # <<<<<<<<<<<<<<
 *                'reads_pp_fwd': self.pp.fwd,
 *                'reads_pp_rev': self.pp.rev,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":401
 *                'reads_rev': self.all.rev,
 *                'reads_pp': self.pp.all,
 *                'reads_pp_fwd': self.pp.fwd,             # <<<<<<<<<<<<<<
 *                'reads_pp_rev': self.pp.rev,
 *                'reads_mate_unmapped': self.mate_unmapped.all,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":402
 *                'reads_pp': self.pp.all,
 *                'reads_pp_fwd': self.pp.fwd,
 *                'reads_pp_rev': self.pp.rev,             # <<<<<<<<<<<<<<
 *                'reads_mate_unmapped': self.mate_unmapped.all,
 *                'reads_mate_unmapped_fwd': self.mate_unmapped.fwd,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":403
 *                'reads_pp_fwd': self.pp.fwd,
 *                'reads_pp_rev': self.pp.rev,
 *                'reads_mate_unmapped': self.mate_unmapped.all,             # <<<<<<<<<<<<<<
 *                'reads_mate_unmapped_fwd': self.mate_unmapped.fwd,
 *                'reads_mate_unmapped_rev': self.mate_unmapped.rev,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->mate_unmapped->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_unmapped, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":404
 *                'reads_pp_rev': self.pp.rev,
 *                'reads_mate_unmapped': self.mate_unmapped.all,
 *                'reads_mate_unmapped_fwd': self.mate_unmapped.fwd,             # <<<<<<<<<<<<<<
 *                'reads_mate_unmapped_rev': self.mate_unmapped.rev,
 *                'reads_mate_other_chr': self.mate_other_chr.all,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->mate_unmapped->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_unmapped_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":405
 *                'reads_mate_unmapped': self.mate_unmapped.all,
 *                'reads_mate_unmapped_fwd': self.mate_unmapped.fwd,
 *                'reads_mate_unmapped_rev': self.mate_unmapped.rev,             # <<<<<<<<<<<<<<
 *                'reads_mate_other_chr': self.mate_other_chr.all,
 *                'reads_mate_other_chr_fwd': self.mate_other_chr.fwd,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->mate_unmapped->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_unmapped_rev, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":406
 *                'reads_mate_unmapped_fwd': self.mate_unmapped.fwd,
 *                'reads_mate_unmapped_rev': self.mate_unmapped.rev,
 *                'reads_mate_other_chr': self.mate_other_chr.all,             # <<<<<<<<<<<<<<
 *                'reads_mate_other_chr_fwd': self.mate_other_chr.fwd,
 *                'reads_mate_other_chr_rev': self.mate_other_chr.rev,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->mate_other_chr->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_other_chr, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":407
 *                'reads_mate_unmapped_rev': self.mate_unmapped.rev,
 *                'reads_mate_other_chr': self.mate_other_chr.all,
 *                'reads_mate_other_chr_fwd': self.mate_other_chr.fwd,             # <<<<<<<<<<<<<<
 *                'reads_mate_other_chr_rev': self.mate_other_chr.rev,
 *                'reads_mate_same_strand': self.same_strand.all,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->mate_other_chr->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_other_chr_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":408
 *                'reads_mate_other_chr': self.mate_other_chr.all,
 *                'reads_mate_other_chr_fwd': self.mate_other_chr.fwd,
 *                'reads_mate_other_chr_rev': self.mate_other_chr.rev,             # <<<<<<<<<<<<<<
 *                'reads_mate_same_strand': self.same_strand.all,
 *                'reads_mate_same_strand_fwd': self.same_strand.fwd,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->mate_other_chr->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_other_chr_rev, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":409
 *                'reads_mate_other_chr_fwd': self.mate_other_chr.fwd,
 *                'reads_mate_other_chr_rev': self.mate_other_chr.rev,
 *                'reads_mate_same_strand': self.same_strand.all,             # <<<<<<<<<<<<<<
 *                'reads_mate_same_strand_fwd': self.same_strand.fwd,
 *                'reads_mate_same_strand_rev': self.same_strand.rev,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->same_strand->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_same_strand, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":410
 *                'reads_mate_other_chr_rev': self.mate_other_chr.rev,
 *                'reads_mate_same_strand': self.same_strand.all,
 *                'reads_mate_same_strand_fwd': self.same_strand.fwd,             # <<<<<<<<<<<<<<
 *                'reads_mate_same_strand_rev': self.same_strand.rev,
 *                'reads_faceaway': self.faceaway.all,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->same_strand->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_same_strand_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":411
 *                'reads_mate_same_strand': self.same_strand.all,
 *                'reads_mate_same_strand_fwd': self.same_strand.fwd,
 *                'reads_mate_same_strand_rev': self.same_strand.rev,             # <<<<<<<<<<<<<<
 *                'reads_faceaway': self.faceaway.all,
 *                'reads_faceaway_fwd': self.faceaway.fwd,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->same_strand->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_same_strand_rev, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":412
 *                'reads_mate_same_strand_fwd': self.same_strand.fwd,
 *                'reads_mate_same_strand_rev': self.same_strand.rev,
 *                'reads_faceaway': self.faceaway.all,             # <<<<<<<<<<<<<<
 *                'reads_faceaway_fwd': self.faceaway.fwd,
 *                'reads_faceaway_rev': self.faceaway.rev,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->faceaway->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_faceaway, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":413
 *                'reads_mate_same_strand_rev': self.same_strand.rev,
 *                'reads_faceaway': self.faceaway.all,
 *                'reads_faceaway_fwd': self.faceaway.fwd,             # <<<<<<<<<<<<<<
 *                'reads_faceaway_rev': self.faceaway.rev,
 *                'reads_softclipped': self.softclipped.all,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->faceaway->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_faceaway_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":414
 *                'reads_faceaway': self.faceaway.all,
 *                'reads_faceaway_fwd': self.faceaway.fwd,
 *                'reads_faceaway_rev': self.faceaway.rev,             # <<<<<<<<<<<<<<
 *                'reads_softclipped': self.softclipped.all,
 *                'reads_softclipped_fwd': self.softclipped.fwd,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->faceaway->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_faceaway_rev, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":415
 *                'reads_faceaway_fwd': self.faceaway.fwd,
 *                'reads_faceaway_rev': self.faceaway.rev,
 *                'reads_softclipped': self.softclipped.all,             # <<<<<<<<<<<<<<
 *                'reads_softclipped_fwd': self.softclipped.fwd,
 *                'reads_softclipped_rev': self.softclipped.rev,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->softclipped->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_softclipped, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":416
 *                'reads_faceaway_rev': self.faceaway.rev,
 *                'reads_softclipped': self.softclipped.all,
 *                'reads_softclipped_fwd': self.softclipped.fwd,             # <<<<<<<<<<<<<<
 *                'reads_softclipped_rev': self.softclipped.rev,
 *                'reads_duplicate': self.duplicate.all,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->softclipped->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_softclipped_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":417
 *                'reads_softclipped': self.softclipped.all,
 *                'reads_softclipped_fwd': self.softclipped.fwd,
 *                'reads_softclipped_rev': self.softclipped.rev,             # <<<<<<<<<<<<<<
 *                'reads_duplicate': self.duplicate.all,
 *                'reads_duplicate_fwd': self.duplicate.fwd,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->softclipped->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_softclipped_rev, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":418
 *                'reads_softclipped_fwd': self.softclipped.fwd,
 *                'reads_softclipped_rev': self.softclipped.rev,
 *                'reads_duplicate': self.duplicate.all,             # <<<<<<<<<<<<<<
 *                'reads_duplicate_fwd': self.duplicate.fwd,
 *                'reads_duplicate_rev': self.duplicate.rev}
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->duplicate->all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_duplicate, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":419
 *                'reads_softclipped_rev': self.softclipped.rev,
 *                'reads_duplicate': self.duplicate.all,
 *                'reads_duplicate_fwd': self.duplicate.fwd,             # <<<<<<<<<<<<<<
 *                'reads_duplicate_rev': self.duplicate.rev}
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->duplicate->fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_duplicate_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":420
 *                'reads_duplicate': self.duplicate.all,
 *                'reads_duplicate_fwd': self.duplicate.fwd,
 *                'reads_duplicate_rev': self.duplicate.rev}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->duplicate->rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_duplicate_rev, __pyx_t_2) < 0) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":423
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 423, __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_ERR(0, 423, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":425
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":394
 *             self.duplicate.incr(is_reverse)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysamstats.opt.CoverageExtStrand.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":448
 *         CountPp N
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads = CountPp()
 *         self.matches = CountPp()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_9Variation___init__(struct __pyx_obj_10pysamstats_3opt_Variation *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":449
 * 
 *     def __init__(self):
 *         self.reads = CountPp()             # <<<<<<<<<<<<<<
 *         self.matches = CountPp()
 *         self.mismatches = CountPp()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->reads);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->reads));
  __pyx_v_self->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":450
 *     def __init__(self):
 *         self.reads = CountPp()
 *         self.matches = CountPp()             # <<<<<<<<<<<<<<
 *         self.mismatches = CountPp()
 *         self.deletions = CountPp()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->matches);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->matches));
  __pyx_v_self->matches = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":451
 *         self.reads = CountPp()
 *         self.matches = CountPp()
 *         self.mismatches = CountPp()             # <<<<<<<<<<<<<<
 *         self.deletions = CountPp()
 *         self.insertions = CountPp()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mismatches);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mismatches));
  __pyx_v_self->mismatches = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":452
 *         self.matches = CountPp()
 *         self.mismatches = CountPp()
 *         self.deletions = CountPp()             # <<<<<<<<<<<<<<
 *         self.insertions = CountPp()
 *         self.A = CountPp()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->deletions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->deletions));
  __pyx_v_self->deletions = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":453
 *         self.mismatches = CountPp()
 *         self.deletions = CountPp()
 *         self.insertions = CountPp()             # <<<<<<<<<<<<<<
 *         self.A = CountPp()
 *         self.C = CountPp()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->insertions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->insertions));
  __pyx_v_self->insertions = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":454
 *         self.deletions = CountPp()
 *         self.insertions = CountPp()
 *         self.A = CountPp()             # <<<<<<<<<<<<<<
 *         self.C = CountPp()
 *         self.T = CountPp()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->A);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->A));
  __pyx_v_self->A = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":455
 *         self.insertions = CountPp()
 *         self.A = CountPp()
 *         self.C = CountPp()             # <<<<<<<<<<<<<<
 *         self.T = CountPp()
 *         self.G = CountPp()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->C);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->C));
  __pyx_v_self->C = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":456
 *         self.A = CountPp()
 *         self.C = CountPp()
 *         self.T = CountPp()             # <<<<<<<<<<<<<<
 *         self.G = CountPp()
 *         self.N = CountPp()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->T);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->T));
  __pyx_v_self->T = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":457
 *         self.C = CountPp()
 *         self.T = CountPp()
 *         self.G = CountPp()             # <<<<<<<<<<<<<<
 *         self.N = CountPp()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->G);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->G));
  __pyx_v_self->G = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":458
 *         self.T = CountPp()
 *         self.G = CountPp()
 *         self.N = CountPp()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->N);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->N));
  __pyx_v_self->N = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":459
 *         self.G = CountPp()
 *         self.N = CountPp()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 459, __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_ERR(0, 459, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":448
 *         CountPp N
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads = CountPp()
 *         self.matches = CountPp()
 */

  /* 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("pysamstats.opt.Variation.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":461
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 *         self.matches.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_9Variation_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_9Variation_2reset[] = "Variation.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_9Variation_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_9Variation_2reset(((struct __pyx_obj_10pysamstats_3opt_Variation *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_9Variation_2reset(struct __pyx_obj_10pysamstats_3opt_Variation *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":462
 * 
 *     def reset(self):
 *         self.reads.reset()             # <<<<<<<<<<<<<<
 *         self.matches.reset()
 *         self.mismatches.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->reads), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 462, __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_ERR(0, 462, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":463
 *     def reset(self):
 *         self.reads.reset()
 *         self.matches.reset()             # <<<<<<<<<<<<<<
 *         self.mismatches.reset()
 *         self.deletions.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 463, __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_ERR(0, 463, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":464
 *         self.reads.reset()
 *         self.matches.reset()
 *         self.mismatches.reset()             # <<<<<<<<<<<<<<
 *         self.deletions.reset()
 *         self.insertions.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 464, __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_ERR(0, 464, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":465
 *         self.matches.reset()
 *         self.mismatches.reset()
 *         self.deletions.reset()             # <<<<<<<<<<<<<<
 *         self.insertions.reset()
 *         self.A.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->deletions), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 465, __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_ERR(0, 465, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":466
 *         self.mismatches.reset()
 *         self.deletions.reset()
 *         self.insertions.reset()             # <<<<<<<<<<<<<<
 *         self.A.reset()
 *         self.C.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->insertions), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 466, __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_ERR(0, 466, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":467
 *         self.deletions.reset()
 *         self.insertions.reset()
 *         self.A.reset()             # <<<<<<<<<<<<<<
 *         self.C.reset()
 *         self.T.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->A), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 467, __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_ERR(0, 467, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":468
 *         self.insertions.reset()
 *         self.A.reset()
 *         self.C.reset()             # <<<<<<<<<<<<<<
 *         self.T.reset()
 *         self.G.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->C), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 468, __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_ERR(0, 468, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":469
 *         self.A.reset()
 *         self.C.reset()
 *         self.T.reset()             # <<<<<<<<<<<<<<
 *         self.G.reset()
 *         self.N.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->T), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 469, __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_ERR(0, 469, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":470
 *         self.C.reset()
 *         self.T.reset()
 *         self.G.reset()             # <<<<<<<<<<<<<<
 *         self.N.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->G), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 470, __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_ERR(0, 470, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":471
 *         self.T.reset()
 *         self.G.reset()
 *         self.N.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->N), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 471, __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_ERR(0, 471, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":461
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 *         self.matches.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.Variation.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":473
 *         self.N.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_9Variation_recv(struct __pyx_obj_10pysamstats_3opt_Variation *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  PyObject *__pyx_v_alnbase = 0;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":480
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 * 
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":481
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":484
 * 
 *         # do the counting
 *         self.reads.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *         if read.is_del:
 *             if not read.is_refskip:
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->reads->__pyx_vtab)->incr(__pyx_v_self->reads, __pyx_v_is_proper_pair);

  /* "pysamstats/opt.pyx":485
 *         # do the counting
 *         self.reads.incr(is_proper_pair)
 *         if read.is_del:             # <<<<<<<<<<<<<<
 *             if not read.is_refskip:
 *                 self.deletions.incr(is_proper_pair)
 */
  __pyx_t_2 = (__pyx_v_read->is_del != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":486
 *         self.reads.incr(is_proper_pair)
 *         if read.is_del:
 *             if not read.is_refskip:             # <<<<<<<<<<<<<<
 *                 self.deletions.incr(is_proper_pair)
 *         else:
 */
    __pyx_t_2 = ((!(__pyx_v_read->is_refskip != 0)) != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":487
 *         if read.is_del:
 *             if not read.is_refskip:
 *                 self.deletions.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *         else:
 *             alnbase = get_seq_base(read.b, read.qpos)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->deletions->__pyx_vtab)->incr(__pyx_v_self->deletions, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":486
 *         self.reads.incr(is_proper_pair)
 *         if read.is_del:
 *             if not read.is_refskip:             # <<<<<<<<<<<<<<
 *                 self.deletions.incr(is_proper_pair)
 *         else:
 */
    }

    /* "pysamstats/opt.pyx":485
 *         # do the counting
 *         self.reads.incr(is_proper_pair)
 *         if read.is_del:             # <<<<<<<<<<<<<<
 *             if not read.is_refskip:
 *                 self.deletions.incr(is_proper_pair)
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":489
 *                 self.deletions.incr(is_proper_pair)
 *         else:
 *             alnbase = get_seq_base(read.b, read.qpos)             # <<<<<<<<<<<<<<
 *             if alnbase == b'A':
 *                 self.A.incr(is_proper_pair)
 */
  /*else*/ {
    __pyx_t_3 = __pyx_f_10pysamstats_3opt_get_seq_base(__pyx_v_read->b, __pyx_v_read->qpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 489, __pyx_L1_error)
    __pyx_v_alnbase = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysamstats/opt.pyx":490
 *         else:
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == b'A':             # <<<<<<<<<<<<<<
 *                 self.A.incr(is_proper_pair)
 *             elif alnbase == b'T':
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_A, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 490, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":491
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == b'A':
 *                 self.A.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *             elif alnbase == b'T':
 *                 self.T.incr(is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->A->__pyx_vtab)->incr(__pyx_v_self->A, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":490
 *         else:
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == b'A':             # <<<<<<<<<<<<<<
 *                 self.A.incr(is_proper_pair)
 *             elif alnbase == b'T':
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":492
 *             if alnbase == b'A':
 *                 self.A.incr(is_proper_pair)
 *             elif alnbase == b'T':             # <<<<<<<<<<<<<<
 *                 self.T.incr(is_proper_pair)
 *             elif alnbase == b'C':
 */
    __pyx_t_4 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_T, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 492, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":493
 *                 self.A.incr(is_proper_pair)
 *             elif alnbase == b'T':
 *                 self.T.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *             elif alnbase == b'C':
 *                 self.C.incr(is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->T->__pyx_vtab)->incr(__pyx_v_self->T, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":492
 *             if alnbase == b'A':
 *                 self.A.incr(is_proper_pair)
 *             elif alnbase == b'T':             # <<<<<<<<<<<<<<
 *                 self.T.incr(is_proper_pair)
 *             elif alnbase == b'C':
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":494
 *             elif alnbase == b'T':
 *                 self.T.incr(is_proper_pair)
 *             elif alnbase == b'C':             # <<<<<<<<<<<<<<
 *                 self.C.incr(is_proper_pair)
 *             elif alnbase == b'G':
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_C, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 494, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":495
 *                 self.T.incr(is_proper_pair)
 *             elif alnbase == b'C':
 *                 self.C.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *             elif alnbase == b'G':
 *                 self.G.incr(is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->C->__pyx_vtab)->incr(__pyx_v_self->C, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":494
 *             elif alnbase == b'T':
 *                 self.T.incr(is_proper_pair)
 *             elif alnbase == b'C':             # <<<<<<<<<<<<<<
 *                 self.C.incr(is_proper_pair)
 *             elif alnbase == b'G':
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":496
 *             elif alnbase == b'C':
 *                 self.C.incr(is_proper_pair)
 *             elif alnbase == b'G':             # <<<<<<<<<<<<<<
 *                 self.G.incr(is_proper_pair)
 *             elif alnbase == b'N':
 */
    __pyx_t_4 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_G, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 496, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":497
 *                 self.C.incr(is_proper_pair)
 *             elif alnbase == b'G':
 *                 self.G.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *             elif alnbase == b'N':
 *                 self.N.incr(is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->G->__pyx_vtab)->incr(__pyx_v_self->G, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":496
 *             elif alnbase == b'C':
 *                 self.C.incr(is_proper_pair)
 *             elif alnbase == b'G':             # <<<<<<<<<<<<<<
 *                 self.G.incr(is_proper_pair)
 *             elif alnbase == b'N':
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":498
 *             elif alnbase == b'G':
 *                 self.G.incr(is_proper_pair)
 *             elif alnbase == b'N':             # <<<<<<<<<<<<<<
 *                 self.N.incr(is_proper_pair)
 *             if read.indel > 0:
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_N, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 498, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":499
 *                 self.G.incr(is_proper_pair)
 *             elif alnbase == b'N':
 *                 self.N.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *             if read.indel > 0:
 *                 self.insertions.incr(is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->N->__pyx_vtab)->incr(__pyx_v_self->N, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":498
 *             elif alnbase == b'G':
 *                 self.G.incr(is_proper_pair)
 *             elif alnbase == b'N':             # <<<<<<<<<<<<<<
 *                 self.N.incr(is_proper_pair)
 *             if read.indel > 0:
 */
    }
    __pyx_L5:;

    /* "pysamstats/opt.pyx":500
 *             elif alnbase == b'N':
 *                 self.N.incr(is_proper_pair)
 *             if read.indel > 0:             # <<<<<<<<<<<<<<
 *                 self.insertions.incr(is_proper_pair)
 *             if alnbase == refbase:
 */
    __pyx_t_4 = ((__pyx_v_read->indel > 0) != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":501
 *                 self.N.incr(is_proper_pair)
 *             if read.indel > 0:
 *                 self.insertions.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *             if alnbase == refbase:
 *                 self.matches.incr(is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->insertions->__pyx_vtab)->incr(__pyx_v_self->insertions, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":500
 *             elif alnbase == b'N':
 *                 self.N.incr(is_proper_pair)
 *             if read.indel > 0:             # <<<<<<<<<<<<<<
 *                 self.insertions.incr(is_proper_pair)
 *             if alnbase == refbase:
 */
    }

    /* "pysamstats/opt.pyx":502
 *             if read.indel > 0:
 *                 self.insertions.incr(is_proper_pair)
 *             if alnbase == refbase:             # <<<<<<<<<<<<<<
 *                 self.matches.incr(is_proper_pair)
 *             else:
 */
    __pyx_t_4 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_v_refbase, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 502, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":503
 *                 self.insertions.incr(is_proper_pair)
 *             if alnbase == refbase:
 *                 self.matches.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.mismatches.incr(is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->matches->__pyx_vtab)->incr(__pyx_v_self->matches, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":502
 *             if read.indel > 0:
 *                 self.insertions.incr(is_proper_pair)
 *             if alnbase == refbase:             # <<<<<<<<<<<<<<
 *                 self.matches.incr(is_proper_pair)
 *             else:
 */
      goto __pyx_L7;
    }

    /* "pysamstats/opt.pyx":505
 *                 self.matches.incr(is_proper_pair)
 *             else:
 *                 self.mismatches.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->mismatches->__pyx_vtab)->incr(__pyx_v_self->mismatches, __pyx_v_is_proper_pair);
    }
    __pyx_L7:;
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":473
 *         self.N.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("pysamstats.opt.Variation.recv", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_alnbase);
  __Pyx_RefNannyFinishContext();
}

/* "pysamstats/opt.pyx":507
 *                 self.mismatches.incr(is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_9Variation_rec(struct __pyx_obj_10pysamstats_3opt_Variation *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_ref = NULL;
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":510
 * 
 *         # make record
 *         if PY2:             # <<<<<<<<<<<<<<
 *             ref = refbase
 *         else:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 510, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":511
 *         # make record
 *         if PY2:
 *             ref = refbase             # <<<<<<<<<<<<<<
 *         else:
 *             ref = str(refbase, 'ascii')
 */
    __Pyx_INCREF(__pyx_v_refbase);
    __pyx_v_ref = __pyx_v_refbase;

    /* "pysamstats/opt.pyx":510
 * 
 *         # make record
 *         if PY2:             # <<<<<<<<<<<<<<
 *             ref = refbase
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":513
 *             ref = refbase
 *         else:
 *             ref = str(refbase, 'ascii')             # <<<<<<<<<<<<<<
 *         rec = {'ref': ref,
 *                'reads_all': self.reads.all,
 */
  /*else*/ {
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_refbase);
    __Pyx_GIVEREF(__pyx_v_refbase);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_refbase);
    __Pyx_INCREF(__pyx_n_s_ascii);
    __Pyx_GIVEREF(__pyx_n_s_ascii);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ascii);
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_ref = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":514
 *         else:
 *             ref = str(refbase, 'ascii')
 *         rec = {'ref': ref,             # <<<<<<<<<<<<<<
 *                'reads_all': self.reads.all,
 *                'reads_pp': self.reads.pp,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ref, __pyx_v_ref) < 0) __PYX_ERR(0, 514, __pyx_L1_error)

  /* "pysamstats/opt.pyx":515
 *             ref = str(refbase, 'ascii')
 *         rec = {'ref': ref,
 *                'reads_all': self.reads.all,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.reads.pp,
 *                'matches': self.matches.all,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->reads->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_all, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":516
 *         rec = {'ref': ref,
 *                'reads_all': self.reads.all,
 *                'reads_pp': self.reads.pp,             # <<<<<<<<<<<<<<
 *                'matches': self.matches.all,
 *                'matches_pp': self.matches.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 516, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":517
 *                'reads_all': self.reads.all,
 *                'reads_pp': self.reads.pp,
 *                'matches': self.matches.all,             # <<<<<<<<<<<<<<
 *                'matches_pp': self.matches.pp,
 *                'mismatches': self.mismatches.all,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":518
 *                'reads_pp': self.reads.pp,
 *                'matches': self.matches.all,
 *                'matches_pp': self.matches.pp,             # <<<<<<<<<<<<<<
 *                'mismatches': self.mismatches.all,
 *                'mismatches_pp': self.mismatches.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":519
 *                'matches': self.matches.all,
 *                'matches_pp': self.matches.pp,
 *                'mismatches': self.mismatches.all,             # <<<<<<<<<<<<<<
 *                'mismatches_pp': self.mismatches.pp,
 *                'deletions': self.deletions.all,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":520
 *                'matches_pp': self.matches.pp,
 *                'mismatches': self.mismatches.all,
 *                'mismatches_pp': self.mismatches.pp,             # <<<<<<<<<<<<<<
 *                'deletions': self.deletions.all,
 *                'deletions_pp': self.deletions.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 520, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":521
 *                'mismatches': self.mismatches.all,
 *                'mismatches_pp': self.mismatches.pp,
 *                'deletions': self.deletions.all,             # <<<<<<<<<<<<<<
 *                'deletions_pp': self.deletions.pp,
 *                'insertions': self.insertions.all,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->deletions->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 521, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deletions, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":522
 *                'mismatches_pp': self.mismatches.pp,
 *                'deletions': self.deletions.all,
 *                'deletions_pp': self.deletions.pp,             # <<<<<<<<<<<<<<
 *                'insertions': self.insertions.all,
 *                'insertions_pp': self.insertions.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->deletions->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 522, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deletions_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":523
 *                'deletions': self.deletions.all,
 *                'deletions_pp': self.deletions.pp,
 *                'insertions': self.insertions.all,             # <<<<<<<<<<<<<<
 *                'insertions_pp': self.insertions.pp,
 *                'A': self.A.all, 'A_pp': self.A.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->insertions->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_insertions, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":524
 *                'deletions_pp': self.deletions.pp,
 *                'insertions': self.insertions.all,
 *                'insertions_pp': self.insertions.pp,             # <<<<<<<<<<<<<<
 *                'A': self.A.all, 'A_pp': self.A.pp,
 *                'C': self.C.all, 'C_pp': self.C.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->insertions->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_insertions_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":525
 *                'insertions': self.insertions.all,
 *                'insertions_pp': self.insertions.pp,
 *                'A': self.A.all, 'A_pp': self.A.pp,             # <<<<<<<<<<<<<<
 *                'C': self.C.all, 'C_pp': self.C.pp,
 *                'T': self.T.all, 'T_pp': self.T.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_A, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_A_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":526
 *                'insertions_pp': self.insertions.pp,
 *                'A': self.A.all, 'A_pp': self.A.pp,
 *                'C': self.C.all, 'C_pp': self.C.pp,             # <<<<<<<<<<<<<<
 *                'T': self.T.all, 'T_pp': self.T.pp,
 *                'G': self.G.all, 'G_pp': self.G.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->C->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_C, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->C->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_C_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":527
 *                'A': self.A.all, 'A_pp': self.A.pp,
 *                'C': self.C.all, 'C_pp': self.C.pp,
 *                'T': self.T.all, 'T_pp': self.T.pp,             # <<<<<<<<<<<<<<
 *                'G': self.G.all, 'G_pp': self.G.pp,
 *                'N': self.N.all, 'N_pp': self.N.pp}
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_T, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_T_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":528
 *                'C': self.C.all, 'C_pp': self.C.pp,
 *                'T': self.T.all, 'T_pp': self.T.pp,
 *                'G': self.G.all, 'G_pp': self.G.pp,             # <<<<<<<<<<<<<<
 *                'N': self.N.all, 'N_pp': self.N.pp}
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->G->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_G, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->G->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_G_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":529
 *                'T': self.T.all, 'T_pp': self.T.pp,
 *                'G': self.G.all, 'G_pp': self.G.pp,
 *                'N': self.N.all, 'N_pp': self.N.pp}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->N->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_N, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->N->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_N_pp, __pyx_t_1) < 0) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":532
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __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;

  /* "pysamstats/opt.pyx":534
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":507
 *                 self.mismatches.incr(is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysamstats.opt.Variation.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref);
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":557
 *         CountPpStrand N
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads = CountPpStrand()
 *         self.matches = CountPpStrand()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_15VariationStrand___init__(struct __pyx_obj_10pysamstats_3opt_VariationStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":558
 * 
 *     def __init__(self):
 *         self.reads = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.matches = CountPpStrand()
 *         self.mismatches = CountPpStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->reads);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->reads));
  __pyx_v_self->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":559
 *     def __init__(self):
 *         self.reads = CountPpStrand()
 *         self.matches = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.mismatches = CountPpStrand()
 *         self.deletions = CountPpStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->matches);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->matches));
  __pyx_v_self->matches = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":560
 *         self.reads = CountPpStrand()
 *         self.matches = CountPpStrand()
 *         self.mismatches = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.deletions = CountPpStrand()
 *         self.insertions = CountPpStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mismatches);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mismatches));
  __pyx_v_self->mismatches = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":561
 *         self.matches = CountPpStrand()
 *         self.mismatches = CountPpStrand()
 *         self.deletions = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.insertions = CountPpStrand()
 *         self.A = CountPpStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->deletions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->deletions));
  __pyx_v_self->deletions = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":562
 *         self.mismatches = CountPpStrand()
 *         self.deletions = CountPpStrand()
 *         self.insertions = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.A = CountPpStrand()
 *         self.C = CountPpStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->insertions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->insertions));
  __pyx_v_self->insertions = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":563
 *         self.deletions = CountPpStrand()
 *         self.insertions = CountPpStrand()
 *         self.A = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.C = CountPpStrand()
 *         self.T = CountPpStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->A);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->A));
  __pyx_v_self->A = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":564
 *         self.insertions = CountPpStrand()
 *         self.A = CountPpStrand()
 *         self.C = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.T = CountPpStrand()
 *         self.G = CountPpStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->C);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->C));
  __pyx_v_self->C = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":565
 *         self.A = CountPpStrand()
 *         self.C = CountPpStrand()
 *         self.T = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.G = CountPpStrand()
 *         self.N = CountPpStrand()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->T);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->T));
  __pyx_v_self->T = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":566
 *         self.C = CountPpStrand()
 *         self.T = CountPpStrand()
 *         self.G = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.N = CountPpStrand()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->G);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->G));
  __pyx_v_self->G = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":567
 *         self.T = CountPpStrand()
 *         self.G = CountPpStrand()
 *         self.N = CountPpStrand()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPpStrand), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->N);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->N));
  __pyx_v_self->N = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":568
 *         self.G = CountPpStrand()
 *         self.N = CountPpStrand()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 568, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 568, __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_ERR(0, 568, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":557
 *         CountPpStrand N
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads = CountPpStrand()
 *         self.matches = CountPpStrand()
 */

  /* 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("pysamstats.opt.VariationStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":570
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 *         self.matches.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_15VariationStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_15VariationStrand_2reset[] = "VariationStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_15VariationStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_15VariationStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_VariationStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_15VariationStrand_2reset(struct __pyx_obj_10pysamstats_3opt_VariationStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":571
 * 
 *     def reset(self):
 *         self.reads.reset()             # <<<<<<<<<<<<<<
 *         self.matches.reset()
 *         self.mismatches.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->reads), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 571, __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_ERR(0, 571, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":572
 *     def reset(self):
 *         self.reads.reset()
 *         self.matches.reset()             # <<<<<<<<<<<<<<
 *         self.mismatches.reset()
 *         self.deletions.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 572, __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_ERR(0, 572, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":573
 *         self.reads.reset()
 *         self.matches.reset()
 *         self.mismatches.reset()             # <<<<<<<<<<<<<<
 *         self.deletions.reset()
 *         self.insertions.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 573, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 573, __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_ERR(0, 573, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":574
 *         self.matches.reset()
 *         self.mismatches.reset()
 *         self.deletions.reset()             # <<<<<<<<<<<<<<
 *         self.insertions.reset()
 *         self.A.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->deletions), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 574, __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_ERR(0, 574, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":575
 *         self.mismatches.reset()
 *         self.deletions.reset()
 *         self.insertions.reset()             # <<<<<<<<<<<<<<
 *         self.A.reset()
 *         self.T.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->insertions), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 575, __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_ERR(0, 575, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":576
 *         self.deletions.reset()
 *         self.insertions.reset()
 *         self.A.reset()             # <<<<<<<<<<<<<<
 *         self.T.reset()
 *         self.C.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->A), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 576, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 576, __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_ERR(0, 576, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":577
 *         self.insertions.reset()
 *         self.A.reset()
 *         self.T.reset()             # <<<<<<<<<<<<<<
 *         self.C.reset()
 *         self.G.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->T), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 577, __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_ERR(0, 577, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":578
 *         self.A.reset()
 *         self.T.reset()
 *         self.C.reset()             # <<<<<<<<<<<<<<
 *         self.G.reset()
 *         self.N.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->C), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 578, __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_ERR(0, 578, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":579
 *         self.T.reset()
 *         self.C.reset()
 *         self.G.reset()             # <<<<<<<<<<<<<<
 *         self.N.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->G), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 579, __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_ERR(0, 579, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":580
 *         self.C.reset()
 *         self.G.reset()
 *         self.N.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->N), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 580, __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_ERR(0, 580, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":570
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 *         self.matches.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.VariationStrand.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":582
 *         self.N.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_15VariationStrand_recv(struct __pyx_obj_10pysamstats_3opt_VariationStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  PyObject *__pyx_v_alnbase = 0;
  int __pyx_v_is_reverse;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":589
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":590
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 * 
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":591
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":594
 * 
 *         # do the counting
 *         self.reads.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *         if read.is_del:
 *             if not read.is_refskip:
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->reads->__pyx_vtab)->incr(__pyx_v_self->reads, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

  /* "pysamstats/opt.pyx":595
 *         # do the counting
 *         self.reads.incr(is_reverse, is_proper_pair)
 *         if read.is_del:             # <<<<<<<<<<<<<<
 *             if not read.is_refskip:
 *                 self.deletions.incr(is_reverse, is_proper_pair)
 */
  __pyx_t_2 = (__pyx_v_read->is_del != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":596
 *         self.reads.incr(is_reverse, is_proper_pair)
 *         if read.is_del:
 *             if not read.is_refskip:             # <<<<<<<<<<<<<<
 *                 self.deletions.incr(is_reverse, is_proper_pair)
 *         else:
 */
    __pyx_t_2 = ((!(__pyx_v_read->is_refskip != 0)) != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":597
 *         if read.is_del:
 *             if not read.is_refskip:
 *                 self.deletions.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *         else:
 *             alnbase = get_seq_base(read.b, read.qpos)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->deletions->__pyx_vtab)->incr(__pyx_v_self->deletions, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":596
 *         self.reads.incr(is_reverse, is_proper_pair)
 *         if read.is_del:
 *             if not read.is_refskip:             # <<<<<<<<<<<<<<
 *                 self.deletions.incr(is_reverse, is_proper_pair)
 *         else:
 */
    }

    /* "pysamstats/opt.pyx":595
 *         # do the counting
 *         self.reads.incr(is_reverse, is_proper_pair)
 *         if read.is_del:             # <<<<<<<<<<<<<<
 *             if not read.is_refskip:
 *                 self.deletions.incr(is_reverse, is_proper_pair)
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":599
 *                 self.deletions.incr(is_reverse, is_proper_pair)
 *         else:
 *             alnbase = get_seq_base(read.b, read.qpos)             # <<<<<<<<<<<<<<
 *             if alnbase == b'A':
 *                 self.A.incr(is_reverse, is_proper_pair)
 */
  /*else*/ {
    __pyx_t_3 = __pyx_f_10pysamstats_3opt_get_seq_base(__pyx_v_read->b, __pyx_v_read->qpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 599, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 599, __pyx_L1_error)
    __pyx_v_alnbase = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysamstats/opt.pyx":600
 *         else:
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == b'A':             # <<<<<<<<<<<<<<
 *                 self.A.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'T':
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_A, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 600, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":601
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == b'A':
 *                 self.A.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *             elif alnbase == b'T':
 *                 self.T.incr(is_reverse, is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->A->__pyx_vtab)->incr(__pyx_v_self->A, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":600
 *         else:
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == b'A':             # <<<<<<<<<<<<<<
 *                 self.A.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'T':
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":602
 *             if alnbase == b'A':
 *                 self.A.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'T':             # <<<<<<<<<<<<<<
 *                 self.T.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'C':
 */
    __pyx_t_4 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_T, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 602, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":603
 *                 self.A.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'T':
 *                 self.T.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *             elif alnbase == b'C':
 *                 self.C.incr(is_reverse, is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->T->__pyx_vtab)->incr(__pyx_v_self->T, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":602
 *             if alnbase == b'A':
 *                 self.A.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'T':             # <<<<<<<<<<<<<<
 *                 self.T.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'C':
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":604
 *             elif alnbase == b'T':
 *                 self.T.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'C':             # <<<<<<<<<<<<<<
 *                 self.C.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'G':
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_C, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 604, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":605
 *                 self.T.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'C':
 *                 self.C.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *             elif alnbase == b'G':
 *                 self.G.incr(is_reverse, is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->C->__pyx_vtab)->incr(__pyx_v_self->C, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":604
 *             elif alnbase == b'T':
 *                 self.T.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'C':             # <<<<<<<<<<<<<<
 *                 self.C.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'G':
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":606
 *             elif alnbase == b'C':
 *                 self.C.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'G':             # <<<<<<<<<<<<<<
 *                 self.G.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'N':
 */
    __pyx_t_4 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_G, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 606, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":607
 *                 self.C.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'G':
 *                 self.G.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *             elif alnbase == b'N':
 *                 self.N.incr(is_reverse, is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->G->__pyx_vtab)->incr(__pyx_v_self->G, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":606
 *             elif alnbase == b'C':
 *                 self.C.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'G':             # <<<<<<<<<<<<<<
 *                 self.G.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'N':
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":608
 *             elif alnbase == b'G':
 *                 self.G.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'N':             # <<<<<<<<<<<<<<
 *                 self.N.incr(is_reverse, is_proper_pair)
 *             if read.indel > 0:
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_n_b_N, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 608, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":609
 *                 self.G.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'N':
 *                 self.N.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *             if read.indel > 0:
 *                 self.insertions.incr(is_reverse, is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->N->__pyx_vtab)->incr(__pyx_v_self->N, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":608
 *             elif alnbase == b'G':
 *                 self.G.incr(is_reverse, is_proper_pair)
 *             elif alnbase == b'N':             # <<<<<<<<<<<<<<
 *                 self.N.incr(is_reverse, is_proper_pair)
 *             if read.indel > 0:
 */
    }
    __pyx_L5:;

    /* "pysamstats/opt.pyx":610
 *             elif alnbase == b'N':
 *                 self.N.incr(is_reverse, is_proper_pair)
 *             if read.indel > 0:             # <<<<<<<<<<<<<<
 *                 self.insertions.incr(is_reverse, is_proper_pair)
 *             if alnbase == refbase:
 */
    __pyx_t_4 = ((__pyx_v_read->indel > 0) != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":611
 *                 self.N.incr(is_reverse, is_proper_pair)
 *             if read.indel > 0:
 *                 self.insertions.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *             if alnbase == refbase:
 *                 self.matches.incr(is_reverse, is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->insertions->__pyx_vtab)->incr(__pyx_v_self->insertions, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":610
 *             elif alnbase == b'N':
 *                 self.N.incr(is_reverse, is_proper_pair)
 *             if read.indel > 0:             # <<<<<<<<<<<<<<
 *                 self.insertions.incr(is_reverse, is_proper_pair)
 *             if alnbase == refbase:
 */
    }

    /* "pysamstats/opt.pyx":612
 *             if read.indel > 0:
 *                 self.insertions.incr(is_reverse, is_proper_pair)
 *             if alnbase == refbase:             # <<<<<<<<<<<<<<
 *                 self.matches.incr(is_reverse, is_proper_pair)
 *             else:
 */
    __pyx_t_4 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_v_refbase, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 612, __pyx_L1_error)
    __pyx_t_2 = (__pyx_t_4 != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":613
 *                 self.insertions.incr(is_reverse, is_proper_pair)
 *             if alnbase == refbase:
 *                 self.matches.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.mismatches.incr(is_reverse, is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->matches->__pyx_vtab)->incr(__pyx_v_self->matches, __pyx_v_is_reverse, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":612
 *             if read.indel > 0:
 *                 self.insertions.incr(is_reverse, is_proper_pair)
 *             if alnbase == refbase:             # <<<<<<<<<<<<<<
 *                 self.matches.incr(is_reverse, is_proper_pair)
 *             else:
 */
      goto __pyx_L7;
    }

    /* "pysamstats/opt.pyx":615
 *                 self.matches.incr(is_reverse, is_proper_pair)
 *             else:
 *                 self.mismatches.incr(is_reverse, is_proper_pair)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPpStrand *)__pyx_v_self->mismatches->__pyx_vtab)->incr(__pyx_v_self->mismatches, __pyx_v_is_reverse, __pyx_v_is_proper_pair);
    }
    __pyx_L7:;
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":582
 *         self.N.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("pysamstats.opt.VariationStrand.recv", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_alnbase);
  __Pyx_RefNannyFinishContext();
}

/* "pysamstats/opt.pyx":617
 *                 self.mismatches.incr(is_reverse, is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_15VariationStrand_rec(struct __pyx_obj_10pysamstats_3opt_VariationStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_ref = NULL;
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":620
 * 
 *         # make record
 *         if PY2:             # <<<<<<<<<<<<<<
 *             ref = refbase
 *         else:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 620, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":621
 *         # make record
 *         if PY2:
 *             ref = refbase             # <<<<<<<<<<<<<<
 *         else:
 *             ref = str(refbase, 'ascii')
 */
    __Pyx_INCREF(__pyx_v_refbase);
    __pyx_v_ref = __pyx_v_refbase;

    /* "pysamstats/opt.pyx":620
 * 
 *         # make record
 *         if PY2:             # <<<<<<<<<<<<<<
 *             ref = refbase
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":623
 *             ref = refbase
 *         else:
 *             ref = str(refbase, 'ascii')             # <<<<<<<<<<<<<<
 *         rec = {'ref': ref,
 *                'reads_all': self.reads.all,
 */
  /*else*/ {
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 623, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_refbase);
    __Pyx_GIVEREF(__pyx_v_refbase);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_refbase);
    __Pyx_INCREF(__pyx_n_s_ascii);
    __Pyx_GIVEREF(__pyx_n_s_ascii);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ascii);
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_ref = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":624
 *         else:
 *             ref = str(refbase, 'ascii')
 *         rec = {'ref': ref,             # <<<<<<<<<<<<<<
 *                'reads_all': self.reads.all,
 *                'reads_fwd': self.reads.fwd,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ref, __pyx_v_ref) < 0) __PYX_ERR(0, 624, __pyx_L1_error)

  /* "pysamstats/opt.pyx":625
 *             ref = str(refbase, 'ascii')
 *         rec = {'ref': ref,
 *                'reads_all': self.reads.all,             # <<<<<<<<<<<<<<
 *                'reads_fwd': self.reads.fwd,
 *                'reads_rev': self.reads.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->reads->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_all, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":626
 *         rec = {'ref': ref,
 *                'reads_all': self.reads.all,
 *                'reads_fwd': self.reads.fwd,             # <<<<<<<<<<<<<<
 *                'reads_rev': self.reads.rev,
 *                'reads_pp': self.reads.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->reads->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":627
 *                'reads_all': self.reads.all,
 *                'reads_fwd': self.reads.fwd,
 *                'reads_rev': self.reads.rev,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.reads.pp,
 *                'reads_pp_fwd': self.reads.pp_fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->reads->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":628
 *                'reads_fwd': self.reads.fwd,
 *                'reads_rev': self.reads.rev,
 *                'reads_pp': self.reads.pp,             # <<<<<<<<<<<<<<
 *                'reads_pp_fwd': self.reads.pp_fwd,
 *                'reads_pp_rev': self.reads.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":629
 *                'reads_rev': self.reads.rev,
 *                'reads_pp': self.reads.pp,
 *                'reads_pp_fwd': self.reads.pp_fwd,             # <<<<<<<<<<<<<<
 *                'reads_pp_rev': self.reads.pp_rev,
 *                'matches': self.matches.all,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":630
 *                'reads_pp': self.reads.pp,
 *                'reads_pp_fwd': self.reads.pp_fwd,
 *                'reads_pp_rev': self.reads.pp_rev,             # <<<<<<<<<<<<<<
 *                'matches': self.matches.all,
 *                'matches_fwd': self.matches.fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":631
 *                'reads_pp_fwd': self.reads.pp_fwd,
 *                'reads_pp_rev': self.reads.pp_rev,
 *                'matches': self.matches.all,             # <<<<<<<<<<<<<<
 *                'matches_fwd': self.matches.fwd,
 *                'matches_rev': self.matches.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":632
 *                'reads_pp_rev': self.reads.pp_rev,
 *                'matches': self.matches.all,
 *                'matches_fwd': self.matches.fwd,             # <<<<<<<<<<<<<<
 *                'matches_rev': self.matches.rev,
 *                'matches_pp': self.matches.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":633
 *                'matches': self.matches.all,
 *                'matches_fwd': self.matches.fwd,
 *                'matches_rev': self.matches.rev,             # <<<<<<<<<<<<<<
 *                'matches_pp': self.matches.pp,
 *                'matches_pp_fwd': self.matches.pp_fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":634
 *                'matches_fwd': self.matches.fwd,
 *                'matches_rev': self.matches.rev,
 *                'matches_pp': self.matches.pp,             # <<<<<<<<<<<<<<
 *                'matches_pp_fwd': self.matches.pp_fwd,
 *                'matches_pp_rev': self.matches.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":635
 *                'matches_rev': self.matches.rev,
 *                'matches_pp': self.matches.pp,
 *                'matches_pp_fwd': self.matches.pp_fwd,             # <<<<<<<<<<<<<<
 *                'matches_pp_rev': self.matches.pp_rev,
 *                'mismatches': self.mismatches.all,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":636
 *                'matches_pp': self.matches.pp,
 *                'matches_pp_fwd': self.matches.pp_fwd,
 *                'matches_pp_rev': self.matches.pp_rev,             # <<<<<<<<<<<<<<
 *                'mismatches': self.mismatches.all,
 *                'mismatches_fwd': self.mismatches.fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":637
 *                'matches_pp_fwd': self.matches.pp_fwd,
 *                'matches_pp_rev': self.matches.pp_rev,
 *                'mismatches': self.mismatches.all,             # <<<<<<<<<<<<<<
 *                'mismatches_fwd': self.mismatches.fwd,
 *                'mismatches_rev': self.mismatches.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":638
 *                'matches_pp_rev': self.matches.pp_rev,
 *                'mismatches': self.mismatches.all,
 *                'mismatches_fwd': self.mismatches.fwd,             # <<<<<<<<<<<<<<
 *                'mismatches_rev': self.mismatches.rev,
 *                'mismatches_pp': self.mismatches.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":639
 *                'mismatches': self.mismatches.all,
 *                'mismatches_fwd': self.mismatches.fwd,
 *                'mismatches_rev': self.mismatches.rev,             # <<<<<<<<<<<<<<
 *                'mismatches_pp': self.mismatches.pp,
 *                'mismatches_pp_fwd': self.mismatches.pp_fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":640
 *                'mismatches_fwd': self.mismatches.fwd,
 *                'mismatches_rev': self.mismatches.rev,
 *                'mismatches_pp': self.mismatches.pp,             # <<<<<<<<<<<<<<
 *                'mismatches_pp_fwd': self.mismatches.pp_fwd,
 *                'mismatches_pp_rev': self.mismatches.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":641
 *                'mismatches_rev': self.mismatches.rev,
 *                'mismatches_pp': self.mismatches.pp,
 *                'mismatches_pp_fwd': self.mismatches.pp_fwd,             # <<<<<<<<<<<<<<
 *                'mismatches_pp_rev': self.mismatches.pp_rev,
 *                'deletions': self.deletions.all,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":642
 *                'mismatches_pp': self.mismatches.pp,
 *                'mismatches_pp_fwd': self.mismatches.pp_fwd,
 *                'mismatches_pp_rev': self.mismatches.pp_rev,             # <<<<<<<<<<<<<<
 *                'deletions': self.deletions.all,
 *                'deletions_fwd': self.deletions.fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":643
 *                'mismatches_pp_fwd': self.mismatches.pp_fwd,
 *                'mismatches_pp_rev': self.mismatches.pp_rev,
 *                'deletions': self.deletions.all,             # <<<<<<<<<<<<<<
 *                'deletions_fwd': self.deletions.fwd,
 *                'deletions_rev': self.deletions.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->deletions->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deletions, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":644
 *                'mismatches_pp_rev': self.mismatches.pp_rev,
 *                'deletions': self.deletions.all,
 *                'deletions_fwd': self.deletions.fwd,             # <<<<<<<<<<<<<<
 *                'deletions_rev': self.deletions.rev,
 *                'deletions_pp': self.deletions.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->deletions->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deletions_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":645
 *                'deletions': self.deletions.all,
 *                'deletions_fwd': self.deletions.fwd,
 *                'deletions_rev': self.deletions.rev,             # <<<<<<<<<<<<<<
 *                'deletions_pp': self.deletions.pp,
 *                'deletions_pp_fwd': self.deletions.pp_fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->deletions->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deletions_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":646
 *                'deletions_fwd': self.deletions.fwd,
 *                'deletions_rev': self.deletions.rev,
 *                'deletions_pp': self.deletions.pp,             # <<<<<<<<<<<<<<
 *                'deletions_pp_fwd': self.deletions.pp_fwd,
 *                'deletions_pp_rev': self.deletions.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->deletions->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deletions_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":647
 *                'deletions_rev': self.deletions.rev,
 *                'deletions_pp': self.deletions.pp,
 *                'deletions_pp_fwd': self.deletions.pp_fwd,             # <<<<<<<<<<<<<<
 *                'deletions_pp_rev': self.deletions.pp_rev,
 *                'insertions': self.insertions.all,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->deletions->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deletions_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":648
 *                'deletions_pp': self.deletions.pp,
 *                'deletions_pp_fwd': self.deletions.pp_fwd,
 *                'deletions_pp_rev': self.deletions.pp_rev,             # <<<<<<<<<<<<<<
 *                'insertions': self.insertions.all,
 *                'insertions_fwd': self.insertions.fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->deletions->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deletions_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":649
 *                'deletions_pp_fwd': self.deletions.pp_fwd,
 *                'deletions_pp_rev': self.deletions.pp_rev,
 *                'insertions': self.insertions.all,             # <<<<<<<<<<<<<<
 *                'insertions_fwd': self.insertions.fwd,
 *                'insertions_rev': self.insertions.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->insertions->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_insertions, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":650
 *                'deletions_pp_rev': self.deletions.pp_rev,
 *                'insertions': self.insertions.all,
 *                'insertions_fwd': self.insertions.fwd,             # <<<<<<<<<<<<<<
 *                'insertions_rev': self.insertions.rev,
 *                'insertions_pp': self.insertions.pp,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->insertions->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 650, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_insertions_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":651
 *                'insertions': self.insertions.all,
 *                'insertions_fwd': self.insertions.fwd,
 *                'insertions_rev': self.insertions.rev,             # <<<<<<<<<<<<<<
 *                'insertions_pp': self.insertions.pp,
 *                'insertions_pp_fwd': self.insertions.pp_fwd,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->insertions->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 651, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_insertions_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":652
 *                'insertions_fwd': self.insertions.fwd,
 *                'insertions_rev': self.insertions.rev,
 *                'insertions_pp': self.insertions.pp,             # <<<<<<<<<<<<<<
 *                'insertions_pp_fwd': self.insertions.pp_fwd,
 *                'insertions_pp_rev': self.insertions.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->insertions->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_insertions_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":653
 *                'insertions_rev': self.insertions.rev,
 *                'insertions_pp': self.insertions.pp,
 *                'insertions_pp_fwd': self.insertions.pp_fwd,             # <<<<<<<<<<<<<<
 *                'insertions_pp_rev': self.insertions.pp_rev,
 *                'A': self.A.all, 'A_fwd': self.A.fwd, 'A_rev': self.A.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->insertions->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_insertions_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":654
 *                'insertions_pp': self.insertions.pp,
 *                'insertions_pp_fwd': self.insertions.pp_fwd,
 *                'insertions_pp_rev': self.insertions.pp_rev,             # <<<<<<<<<<<<<<
 *                'A': self.A.all, 'A_fwd': self.A.fwd, 'A_rev': self.A.rev,
 *                'A_pp': self.A.pp, 'A_pp_fwd': self.A.pp_fwd, 'A_pp_rev': self.A.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->insertions->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_insertions_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":655
 *                'insertions_pp_fwd': self.insertions.pp_fwd,
 *                'insertions_pp_rev': self.insertions.pp_rev,
 *                'A': self.A.all, 'A_fwd': self.A.fwd, 'A_rev': self.A.rev,             # <<<<<<<<<<<<<<
 *                'A_pp': self.A.pp, 'A_pp_fwd': self.A.pp_fwd, 'A_pp_rev': self.A.pp_rev,
 *                'C': self.C.all, 'C_fwd': self.C.fwd, 'C_rev': self.C.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_A, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_A_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 655, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_A_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":656
 *                'insertions_pp_rev': self.insertions.pp_rev,
 *                'A': self.A.all, 'A_fwd': self.A.fwd, 'A_rev': self.A.rev,
 *                'A_pp': self.A.pp, 'A_pp_fwd': self.A.pp_fwd, 'A_pp_rev': self.A.pp_rev,             # <<<<<<<<<<<<<<
 *                'C': self.C.all, 'C_fwd': self.C.fwd, 'C_rev': self.C.rev,
 *                'C_pp': self.C.pp, 'C_pp_fwd': self.C.pp_fwd, 'C_pp_rev': self.C.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_A_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_A_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_A_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":657
 *                'A': self.A.all, 'A_fwd': self.A.fwd, 'A_rev': self.A.rev,
 *                'A_pp': self.A.pp, 'A_pp_fwd': self.A.pp_fwd, 'A_pp_rev': self.A.pp_rev,
 *                'C': self.C.all, 'C_fwd': self.C.fwd, 'C_rev': self.C.rev,             # <<<<<<<<<<<<<<
 *                'C_pp': self.C.pp, 'C_pp_fwd': self.C.pp_fwd, 'C_pp_rev': self.C.pp_rev,
 *                'T': self.T.all, 'T_fwd': self.T.fwd, 'T_rev': self.T.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->C->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_C, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->C->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_C_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->C->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_C_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":658
 *                'A_pp': self.A.pp, 'A_pp_fwd': self.A.pp_fwd, 'A_pp_rev': self.A.pp_rev,
 *                'C': self.C.all, 'C_fwd': self.C.fwd, 'C_rev': self.C.rev,
 *                'C_pp': self.C.pp, 'C_pp_fwd': self.C.pp_fwd, 'C_pp_rev': self.C.pp_rev,             # <<<<<<<<<<<<<<
 *                'T': self.T.all, 'T_fwd': self.T.fwd, 'T_rev': self.T.rev,
 *                'T_pp': self.T.pp, 'T_pp_fwd': self.T.pp_fwd, 'T_pp_rev': self.T.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->C->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_C_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->C->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_C_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->C->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_C_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":659
 *                'C': self.C.all, 'C_fwd': self.C.fwd, 'C_rev': self.C.rev,
 *                'C_pp': self.C.pp, 'C_pp_fwd': self.C.pp_fwd, 'C_pp_rev': self.C.pp_rev,
 *                'T': self.T.all, 'T_fwd': self.T.fwd, 'T_rev': self.T.rev,             # <<<<<<<<<<<<<<
 *                'T_pp': self.T.pp, 'T_pp_fwd': self.T.pp_fwd, 'T_pp_rev': self.T.pp_rev,
 *                'G': self.G.all, 'G_fwd': self.G.fwd, 'G_rev': self.G.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_T, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_T_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_T_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":660
 *                'C_pp': self.C.pp, 'C_pp_fwd': self.C.pp_fwd, 'C_pp_rev': self.C.pp_rev,
 *                'T': self.T.all, 'T_fwd': self.T.fwd, 'T_rev': self.T.rev,
 *                'T_pp': self.T.pp, 'T_pp_fwd': self.T.pp_fwd, 'T_pp_rev': self.T.pp_rev,             # <<<<<<<<<<<<<<
 *                'G': self.G.all, 'G_fwd': self.G.fwd, 'G_rev': self.G.rev,
 *                'G_pp': self.G.pp, 'G_pp_fwd': self.G.pp_fwd, 'G_pp_rev': self.G.pp_rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_T_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_T_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->T->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_T_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":661
 *                'T': self.T.all, 'T_fwd': self.T.fwd, 'T_rev': self.T.rev,
 *                'T_pp': self.T.pp, 'T_pp_fwd': self.T.pp_fwd, 'T_pp_rev': self.T.pp_rev,
 *                'G': self.G.all, 'G_fwd': self.G.fwd, 'G_rev': self.G.rev,             # <<<<<<<<<<<<<<
 *                'G_pp': self.G.pp, 'G_pp_fwd': self.G.pp_fwd, 'G_pp_rev': self.G.pp_rev,
 *                'N': self.N.all, 'N_fwd': self.N.fwd, 'N_rev': self.N.rev,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->G->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_G, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->G->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_G_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->G->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_G_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":662
 *                'T_pp': self.T.pp, 'T_pp_fwd': self.T.pp_fwd, 'T_pp_rev': self.T.pp_rev,
 *                'G': self.G.all, 'G_fwd': self.G.fwd, 'G_rev': self.G.rev,
 *                'G_pp': self.G.pp, 'G_pp_fwd': self.G.pp_fwd, 'G_pp_rev': self.G.pp_rev,             # <<<<<<<<<<<<<<
 *                'N': self.N.all, 'N_fwd': self.N.fwd, 'N_rev': self.N.rev,
 *                'N_pp': self.N.pp, 'N_pp_fwd': self.N.pp_fwd, 'N_pp_rev': self.N.pp_rev}
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->G->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_G_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->G->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_G_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->G->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_G_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":663
 *                'G': self.G.all, 'G_fwd': self.G.fwd, 'G_rev': self.G.rev,
 *                'G_pp': self.G.pp, 'G_pp_fwd': self.G.pp_fwd, 'G_pp_rev': self.G.pp_rev,
 *                'N': self.N.all, 'N_fwd': self.N.fwd, 'N_rev': self.N.rev,             # <<<<<<<<<<<<<<
 *                'N_pp': self.N.pp, 'N_pp_fwd': self.N.pp_fwd, 'N_pp_rev': self.N.pp_rev}
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->N->all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_N, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->N->fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_N_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->N->rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_N_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":664
 *                'G_pp': self.G.pp, 'G_pp_fwd': self.G.pp_fwd, 'G_pp_rev': self.G.pp_rev,
 *                'N': self.N.all, 'N_fwd': self.N.fwd, 'N_rev': self.N.rev,
 *                'N_pp': self.N.pp, 'N_pp_fwd': self.N.pp_fwd, 'N_pp_rev': self.N.pp_rev}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->N->pp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_N_pp, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->N->pp_fwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_N_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->N->pp_rev); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_N_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":667
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __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;

  /* "pysamstats/opt.pyx":669
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":617
 *                 self.mismatches.incr(is_reverse, is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysamstats.opt.VariationStrand.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref);
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":689
 *         int64_t sq  # sum of squares
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_10TlenHelper___init__(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":690
 * 
 *     def __init__(self):
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 690, __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_ERR(0, 690, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":689
 *         int64_t sq  # sum of squares
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

  /* 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("pysamstats.opt.TlenHelper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":692
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.n = 0
 *         self.m = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10TlenHelper_2reset[] = "TlenHelper.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10TlenHelper_2reset(((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_2reset(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":693
 * 
 *     def reset(self):
 *         self.n = 0             # <<<<<<<<<<<<<<
 *         self.m = 0
 *         self.m2 = 0
 */
  __pyx_v_self->n = 0;

  /* "pysamstats/opt.pyx":694
 *     def reset(self):
 *         self.n = 0
 *         self.m = 0             # <<<<<<<<<<<<<<
 *         self.m2 = 0
 *         self.d = 0
 */
  __pyx_v_self->m = 0.0;

  /* "pysamstats/opt.pyx":695
 *         self.n = 0
 *         self.m = 0
 *         self.m2 = 0             # <<<<<<<<<<<<<<
 *         self.d = 0
 *         self.d2 = 0
 */
  __pyx_v_self->m2 = 0.0;

  /* "pysamstats/opt.pyx":696
 *         self.m = 0
 *         self.m2 = 0
 *         self.d = 0             # <<<<<<<<<<<<<<
 *         self.d2 = 0
 *         self.s = 0
 */
  __pyx_v_self->d = 0.0;

  /* "pysamstats/opt.pyx":697
 *         self.m2 = 0
 *         self.d = 0
 *         self.d2 = 0             # <<<<<<<<<<<<<<
 *         self.s = 0
 *         self.sq = 0
 */
  __pyx_v_self->d2 = 0.0;

  /* "pysamstats/opt.pyx":698
 *         self.d = 0
 *         self.d2 = 0
 *         self.s = 0             # <<<<<<<<<<<<<<
 *         self.sq = 0
 * 
 */
  __pyx_v_self->s = 0;

  /* "pysamstats/opt.pyx":699
 *         self.d2 = 0
 *         self.s = 0
 *         self.sq = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void update(self, int64_t x):
 */
  __pyx_v_self->sq = 0;

  /* "pysamstats/opt.pyx":692
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.n = 0
 *         self.m = 0
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":701
 *         self.sq = 0
 * 
 *     cdef void update(self, int64_t x):             # <<<<<<<<<<<<<<
 *         self.n += 1
 *         self.s += x
 */

static void __pyx_f_10pysamstats_3opt_10TlenHelper_update(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self, int64_t __pyx_v_x) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update", 0);

  /* "pysamstats/opt.pyx":702
 * 
 *     cdef void update(self, int64_t x):
 *         self.n += 1             # <<<<<<<<<<<<<<
 *         self.s += x
 *         self.sq += x ** 2
 */
  __pyx_v_self->n = (__pyx_v_self->n + 1);

  /* "pysamstats/opt.pyx":703
 *     cdef void update(self, int64_t x):
 *         self.n += 1
 *         self.s += x             # <<<<<<<<<<<<<<
 *         self.sq += x ** 2
 *         self.d = x - self.m
 */
  __pyx_v_self->s = (__pyx_v_self->s + __pyx_v_x);

  /* "pysamstats/opt.pyx":704
 *         self.n += 1
 *         self.s += x
 *         self.sq += x ** 2             # <<<<<<<<<<<<<<
 *         self.d = x - self.m
 *         self.m += self.d / self.n
 */
  __pyx_v_self->sq = (__pyx_v_self->sq + __Pyx_pow_int64_t(__pyx_v_x, 2));

  /* "pysamstats/opt.pyx":705
 *         self.s += x
 *         self.sq += x ** 2
 *         self.d = x - self.m             # <<<<<<<<<<<<<<
 *         self.m += self.d / self.n
 *         self.d2 = x - self.m
 */
  __pyx_v_self->d = (__pyx_v_x - __pyx_v_self->m);

  /* "pysamstats/opt.pyx":706
 *         self.sq += x ** 2
 *         self.d = x - self.m
 *         self.m += self.d / self.n             # <<<<<<<<<<<<<<
 *         self.d2 = x - self.m
 *         self.m2 += self.d * self.d2
 */
  if (unlikely(__pyx_v_self->n == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 706, __pyx_L1_error)
  }
  __pyx_v_self->m = (__pyx_v_self->m + (__pyx_v_self->d / ((double)__pyx_v_self->n)));

  /* "pysamstats/opt.pyx":707
 *         self.d = x - self.m
 *         self.m += self.d / self.n
 *         self.d2 = x - self.m             # <<<<<<<<<<<<<<
 *         self.m2 += self.d * self.d2
 * 
 */
  __pyx_v_self->d2 = (__pyx_v_x - __pyx_v_self->m);

  /* "pysamstats/opt.pyx":708
 *         self.m += self.d / self.n
 *         self.d2 = x - self.m
 *         self.m2 += self.d * self.d2             # <<<<<<<<<<<<<<
 * 
 *     def variance(self):
 */
  __pyx_v_self->m2 = (__pyx_v_self->m2 + (__pyx_v_self->d * __pyx_v_self->d2));

  /* "pysamstats/opt.pyx":701
 *         self.sq = 0
 * 
 *     cdef void update(self, int64_t x):             # <<<<<<<<<<<<<<
 *         self.n += 1
 *         self.s += x
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("pysamstats.opt.TlenHelper.update", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "pysamstats/opt.pyx":710
 *         self.m2 += self.d * self.d2
 * 
 *     def variance(self):             # <<<<<<<<<<<<<<
 *         if self.n < 2:
 *             return 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_5variance(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10TlenHelper_4variance[] = "TlenHelper.variance(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_5variance(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("variance (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10TlenHelper_4variance(((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_4variance(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  long __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("variance", 0);

  /* "pysamstats/opt.pyx":711
 * 
 *     def variance(self):
 *         if self.n < 2:             # <<<<<<<<<<<<<<
 *             return 0
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->n < 2) != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":712
 *     def variance(self):
 *         if self.n < 2:
 *             return 0             # <<<<<<<<<<<<<<
 *         else:
 *             return int(round(self.m2 / (self.n - 1)))
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_r = __pyx_int_0;
    goto __pyx_L0;

    /* "pysamstats/opt.pyx":711
 * 
 *     def variance(self):
 *         if self.n < 2:             # <<<<<<<<<<<<<<
 *             return 0
 *         else:
 */
  }

  /* "pysamstats/opt.pyx":714
 *             return 0
 *         else:
 *             return int(round(self.m2 / (self.n - 1)))             # <<<<<<<<<<<<<<
 * 
 *     def std(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = (__pyx_v_self->n - 1);
    if (unlikely(__pyx_t_2 == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 714, __pyx_L1_error)
    }
    __pyx_t_3 = PyFloat_FromDouble((__pyx_v_self->m2 / ((double)__pyx_t_2))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 714, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 714, __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_round, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 714, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 714, __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;
    goto __pyx_L0;
  }

  /* "pysamstats/opt.pyx":710
 *         self.m2 += self.d * self.d2
 * 
 *     def variance(self):             # <<<<<<<<<<<<<<
 *         if self.n < 2:
 *             return 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysamstats.opt.TlenHelper.variance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":716
 *             return int(round(self.m2 / (self.n - 1)))
 * 
 *     def std(self):             # <<<<<<<<<<<<<<
 *         if self.n < 2:
 *             return 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_7std(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10TlenHelper_6std[] = "TlenHelper.std(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_7std(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("std (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10TlenHelper_6std(((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_6std(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  long __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("std", 0);

  /* "pysamstats/opt.pyx":717
 * 
 *     def std(self):
 *         if self.n < 2:             # <<<<<<<<<<<<<<
 *             return 0
 *         else:
 */
  __pyx_t_1 = ((__pyx_v_self->n < 2) != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":718
 *     def std(self):
 *         if self.n < 2:
 *             return 0             # <<<<<<<<<<<<<<
 *         else:
 *             return int(round(sqrt(self.m2 / (self.n - 1))))
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_r = __pyx_int_0;
    goto __pyx_L0;

    /* "pysamstats/opt.pyx":717
 * 
 *     def std(self):
 *         if self.n < 2:             # <<<<<<<<<<<<<<
 *             return 0
 *         else:
 */
  }

  /* "pysamstats/opt.pyx":720
 *             return 0
 *         else:
 *             return int(round(sqrt(self.m2 / (self.n - 1))))             # <<<<<<<<<<<<<<
 * 
 *     def mean(self):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = (__pyx_v_self->n - 1);
    if (unlikely(__pyx_t_2 == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 720, __pyx_L1_error)
    }
    __pyx_t_3 = PyFloat_FromDouble(sqrt((__pyx_v_self->m2 / ((double)__pyx_t_2)))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __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_round, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __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;
    goto __pyx_L0;
  }

  /* "pysamstats/opt.pyx":716
 *             return int(round(self.m2 / (self.n - 1)))
 * 
 *     def std(self):             # <<<<<<<<<<<<<<
 *         if self.n < 2:
 *             return 0
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("pysamstats.opt.TlenHelper.std", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":722
 *             return int(round(sqrt(self.m2 / (self.n - 1))))
 * 
 *     def mean(self):             # <<<<<<<<<<<<<<
 *         return mean(self.s, self.n)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_9mean(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10TlenHelper_8mean[] = "TlenHelper.mean(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_9mean(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("mean (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10TlenHelper_8mean(((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_8mean(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__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_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("mean", 0);

  /* "pysamstats/opt.pyx":723
 * 
 *     def mean(self):
 *         return mean(self.s, self.n)             # <<<<<<<<<<<<<<
 * 
 *     def rms(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_mean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_v_self->s); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_self->n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 723, __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_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":722
 *             return int(round(sqrt(self.m2 / (self.n - 1))))
 * 
 *     def mean(self):             # <<<<<<<<<<<<<<
 *         return mean(self.s, self.n)
 * 
 */

  /* 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_7);
  __Pyx_AddTraceback("pysamstats.opt.TlenHelper.mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":725
 *         return mean(self.s, self.n)
 * 
 *     def rms(self):             # <<<<<<<<<<<<<<
 *         return rootmean(self.sq, self.n)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_11rms(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10TlenHelper_10rms[] = "TlenHelper.rms(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenHelper_11rms(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rms (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10TlenHelper_10rms(((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10TlenHelper_10rms(struct __pyx_obj_10pysamstats_3opt_TlenHelper *__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_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("rms", 0);

  /* "pysamstats/opt.pyx":726
 * 
 *     def rms(self):
 *         return rootmean(self.sq, self.n)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_rootmean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_v_self->sq); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_self->n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 726, __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_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":725
 *         return mean(self.s, self.n)
 * 
 *     def rms(self):             # <<<<<<<<<<<<<<
 *         return rootmean(self.sq, self.n)
 * 
 */

  /* 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_7);
  __Pyx_AddTraceback("pysamstats.opt.TlenHelper.rms", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":737
 *         TlenHelper tlen_pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.tlen = TlenHelper()
 *         self.tlen_pp = TlenHelper()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_4Tlen___init__(struct __pyx_obj_10pysamstats_3opt_Tlen *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":738
 * 
 *     def __init__(self):
 *         self.tlen = TlenHelper()             # <<<<<<<<<<<<<<
 *         self.tlen_pp = TlenHelper()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_TlenHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tlen);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->tlen));
  __pyx_v_self->tlen = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":739
 *     def __init__(self):
 *         self.tlen = TlenHelper()
 *         self.tlen_pp = TlenHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_TlenHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tlen_pp);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->tlen_pp));
  __pyx_v_self->tlen_pp = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":740
 *         self.tlen = TlenHelper()
 *         self.tlen_pp = TlenHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 740, __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_ERR(0, 740, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":737
 *         TlenHelper tlen_pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.tlen = TlenHelper()
 *         self.tlen_pp = TlenHelper()
 */

  /* 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("pysamstats.opt.Tlen.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":742
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = 0
 *         self.tlen.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_4Tlen_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_4Tlen_2reset[] = "Tlen.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_4Tlen_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_4Tlen_2reset(((struct __pyx_obj_10pysamstats_3opt_Tlen *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_4Tlen_2reset(struct __pyx_obj_10pysamstats_3opt_Tlen *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":743
 * 
 *     def reset(self):
 *         self.reads_all = 0             # <<<<<<<<<<<<<<
 *         self.tlen.reset()
 *         self.tlen_pp.reset()
 */
  __pyx_v_self->reads_all = 0;

  /* "pysamstats/opt.pyx":744
 *     def reset(self):
 *         self.reads_all = 0
 *         self.tlen.reset()             # <<<<<<<<<<<<<<
 *         self.tlen_pp.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 744, __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_ERR(0, 744, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":745
 *         self.reads_all = 0
 *         self.tlen.reset()
 *         self.tlen_pp.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 745, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 745, __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_ERR(0, 745, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":742
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = 0
 *         self.tlen.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.Tlen.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":747
 *         self.tlen_pp.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_4Tlen_recv(struct __pyx_obj_10pysamstats_3opt_Tlen *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int __pyx_v_mate_other_chr;
  int64_t __pyx_v_tlen;
  int __pyx_v_mate_is_unmapped;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":756
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":757
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_other_chr = <bint>(read.b.core.tid != read.b.core.mtid)
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":758
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)             # <<<<<<<<<<<<<<
 *         mate_other_chr = <bint>(read.b.core.tid != read.b.core.mtid)
 *         tlen = read.b.core.isize
 */
  __pyx_v_mate_is_unmapped = ((__pyx_v_flag & 8) != 0);

  /* "pysamstats/opt.pyx":759
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_other_chr = <bint>(read.b.core.tid != read.b.core.mtid)             # <<<<<<<<<<<<<<
 *         tlen = read.b.core.isize
 * 
 */
  __pyx_v_mate_other_chr = ((__pyx_v_read->b->core.tid != __pyx_v_read->b->core.mtid) != 0);

  /* "pysamstats/opt.pyx":760
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_other_chr = <bint>(read.b.core.tid != read.b.core.mtid)
 *         tlen = read.b.core.isize             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_t_2 = __pyx_v_read->b->core.isize;
  __pyx_v_tlen = __pyx_t_2;

  /* "pysamstats/opt.pyx":763
 * 
 *         # do the counting
 *         self.reads_all += 1             # <<<<<<<<<<<<<<
 *         # N.B. insert size is only meaningful if mate is mapped to same chromosome
 *         if not mate_is_unmapped and not mate_other_chr:
 */
  __pyx_v_self->reads_all = (__pyx_v_self->reads_all + 1);

  /* "pysamstats/opt.pyx":765
 *         self.reads_all += 1
 *         # N.B. insert size is only meaningful if mate is mapped to same chromosome
 *         if not mate_is_unmapped and not mate_other_chr:             # <<<<<<<<<<<<<<
 *             self.tlen.update(tlen)
 *         if is_proper_pair:
 */
  __pyx_t_4 = ((!(__pyx_v_mate_is_unmapped != 0)) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = ((!(__pyx_v_mate_other_chr != 0)) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":766
 *         # N.B. insert size is only meaningful if mate is mapped to same chromosome
 *         if not mate_is_unmapped and not mate_other_chr:
 *             self.tlen.update(tlen)             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.tlen_pp.update(tlen)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *)__pyx_v_self->tlen->__pyx_vtab)->update(__pyx_v_self->tlen, __pyx_v_tlen);

    /* "pysamstats/opt.pyx":765
 *         self.reads_all += 1
 *         # N.B. insert size is only meaningful if mate is mapped to same chromosome
 *         if not mate_is_unmapped and not mate_other_chr:             # <<<<<<<<<<<<<<
 *             self.tlen.update(tlen)
 *         if is_proper_pair:
 */
  }

  /* "pysamstats/opt.pyx":767
 *         if not mate_is_unmapped and not mate_other_chr:
 *             self.tlen.update(tlen)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.tlen_pp.update(tlen)
 * 
 */
  __pyx_t_3 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":768
 *             self.tlen.update(tlen)
 *         if is_proper_pair:
 *             self.tlen_pp.update(tlen)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *)__pyx_v_self->tlen_pp->__pyx_vtab)->update(__pyx_v_self->tlen_pp, __pyx_v_tlen);

    /* "pysamstats/opt.pyx":767
 *         if not mate_is_unmapped and not mate_other_chr:
 *             self.tlen.update(tlen)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.tlen_pp.update(tlen)
 * 
 */
  }

  /* "pysamstats/opt.pyx":747
 *         self.tlen_pp.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":770
 *             self.tlen_pp.update(tlen)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_4Tlen_rec(struct __pyx_obj_10pysamstats_3opt_Tlen *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":773
 * 
 *         # make record
 *         rec = {'reads_all': self.reads_all,             # <<<<<<<<<<<<<<
 *                'reads_paired': self.tlen.n,
 *                'reads_pp': self.tlen_pp.n,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":774
 *         # make record
 *         rec = {'reads_all': self.reads_all,
 *                'reads_paired': self.tlen.n,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.tlen_pp.n,
 *                'mean_tlen': self.tlen.mean(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->tlen->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 774, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_paired, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":775
 *         rec = {'reads_all': self.reads_all,
 *                'reads_paired': self.tlen.n,
 *                'reads_pp': self.tlen_pp.n,             # <<<<<<<<<<<<<<
 *                'mean_tlen': self.tlen.mean(),
 *                'mean_tlen_pp': self.tlen_pp.mean(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->tlen_pp->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 775, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":776
 *                'reads_paired': self.tlen.n,
 *                'reads_pp': self.tlen_pp.n,
 *                'mean_tlen': self.tlen.mean(),             # <<<<<<<<<<<<<<
 *                'mean_tlen_pp': self.tlen_pp.mean(),
 *                'rms_tlen': self.tlen.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 776, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 776, __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_ERR(0, 776, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":777
 *                'reads_pp': self.tlen_pp.n,
 *                'mean_tlen': self.tlen.mean(),
 *                'mean_tlen_pp': self.tlen_pp.mean(),             # <<<<<<<<<<<<<<
 *                'rms_tlen': self.tlen.rms(),
 *                'rms_tlen_pp': self.tlen_pp.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 777, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 777, __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_ERR(0, 777, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen_pp, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":778
 *                'mean_tlen': self.tlen.mean(),
 *                'mean_tlen_pp': self.tlen_pp.mean(),
 *                'rms_tlen': self.tlen.rms(),             # <<<<<<<<<<<<<<
 *                'rms_tlen_pp': self.tlen_pp.rms(),
 *                'std_tlen': self.tlen.std(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 778, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 778, __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_ERR(0, 778, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":779
 *                'mean_tlen_pp': self.tlen_pp.mean(),
 *                'rms_tlen': self.tlen.rms(),
 *                'rms_tlen_pp': self.tlen_pp.rms(),             # <<<<<<<<<<<<<<
 *                'std_tlen': self.tlen.std(),
 *                'std_tlen_pp': self.tlen_pp.std()}
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 779, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 779, __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_ERR(0, 779, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen_pp, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":780
 *                'rms_tlen': self.tlen.rms(),
 *                'rms_tlen_pp': self.tlen_pp.rms(),
 *                'std_tlen': self.tlen.std(),             # <<<<<<<<<<<<<<
 *                'std_tlen_pp': self.tlen_pp.std()}
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen), __pyx_n_s_std); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 780, __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_ERR(0, 780, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_std_tlen, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":781
 *                'rms_tlen_pp': self.tlen_pp.rms(),
 *                'std_tlen': self.tlen.std(),
 *                'std_tlen_pp': self.tlen_pp.std()}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp), __pyx_n_s_std); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 781, __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_ERR(0, 781, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_std_tlen_pp, __pyx_t_2) < 0) __PYX_ERR(0, 773, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":784
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 784, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 784, __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_ERR(0, 784, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":786
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":770
 *             self.tlen_pp.update(tlen)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* 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("pysamstats.opt.Tlen.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":808
 *         TlenHelper tlen_pp_rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.tlen = TlenHelper()
 *         self.tlen_fwd = TlenHelper()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_10TlenStrand___init__(struct __pyx_obj_10pysamstats_3opt_TlenStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":809
 * 
 *     def __init__(self):
 *         self.tlen = TlenHelper()             # <<<<<<<<<<<<<<
 *         self.tlen_fwd = TlenHelper()
 *         self.tlen_rev = TlenHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_TlenHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 809, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tlen);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->tlen));
  __pyx_v_self->tlen = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":810
 *     def __init__(self):
 *         self.tlen = TlenHelper()
 *         self.tlen_fwd = TlenHelper()             # <<<<<<<<<<<<<<
 *         self.tlen_rev = TlenHelper()
 *         self.tlen_pp = TlenHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_TlenHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tlen_fwd);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->tlen_fwd));
  __pyx_v_self->tlen_fwd = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":811
 *         self.tlen = TlenHelper()
 *         self.tlen_fwd = TlenHelper()
 *         self.tlen_rev = TlenHelper()             # <<<<<<<<<<<<<<
 *         self.tlen_pp = TlenHelper()
 *         self.tlen_pp_fwd = TlenHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_TlenHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tlen_rev);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->tlen_rev));
  __pyx_v_self->tlen_rev = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":812
 *         self.tlen_fwd = TlenHelper()
 *         self.tlen_rev = TlenHelper()
 *         self.tlen_pp = TlenHelper()             # <<<<<<<<<<<<<<
 *         self.tlen_pp_fwd = TlenHelper()
 *         self.tlen_pp_rev = TlenHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_TlenHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tlen_pp);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->tlen_pp));
  __pyx_v_self->tlen_pp = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":813
 *         self.tlen_rev = TlenHelper()
 *         self.tlen_pp = TlenHelper()
 *         self.tlen_pp_fwd = TlenHelper()             # <<<<<<<<<<<<<<
 *         self.tlen_pp_rev = TlenHelper()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_TlenHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tlen_pp_fwd);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->tlen_pp_fwd));
  __pyx_v_self->tlen_pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":814
 *         self.tlen_pp = TlenHelper()
 *         self.tlen_pp_fwd = TlenHelper()
 *         self.tlen_pp_rev = TlenHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_TlenHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->tlen_pp_rev);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->tlen_pp_rev));
  __pyx_v_self->tlen_pp_rev = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":815
 *         self.tlen_pp_fwd = TlenHelper()
 *         self.tlen_pp_rev = TlenHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 815, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 815, __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_ERR(0, 815, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":808
 *         TlenHelper tlen_pp_rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.tlen = TlenHelper()
 *         self.tlen_fwd = TlenHelper()
 */

  /* 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("pysamstats.opt.TlenStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":817
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = 0
 *         self.reads_fwd = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10TlenStrand_2reset[] = "TlenStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10TlenStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10TlenStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_TlenStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10TlenStrand_2reset(struct __pyx_obj_10pysamstats_3opt_TlenStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":818
 * 
 *     def reset(self):
 *         self.reads_all = 0             # <<<<<<<<<<<<<<
 *         self.reads_fwd = 0
 *         self.reads_rev = 0
 */
  __pyx_v_self->reads_all = 0;

  /* "pysamstats/opt.pyx":819
 *     def reset(self):
 *         self.reads_all = 0
 *         self.reads_fwd = 0             # <<<<<<<<<<<<<<
 *         self.reads_rev = 0
 *         self.tlen.reset()
 */
  __pyx_v_self->reads_fwd = 0;

  /* "pysamstats/opt.pyx":820
 *         self.reads_all = 0
 *         self.reads_fwd = 0
 *         self.reads_rev = 0             # <<<<<<<<<<<<<<
 *         self.tlen.reset()
 *         self.tlen_fwd.reset()
 */
  __pyx_v_self->reads_rev = 0;

  /* "pysamstats/opt.pyx":821
 *         self.reads_fwd = 0
 *         self.reads_rev = 0
 *         self.tlen.reset()             # <<<<<<<<<<<<<<
 *         self.tlen_fwd.reset()
 *         self.tlen_rev.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 821, __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_ERR(0, 821, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":822
 *         self.reads_rev = 0
 *         self.tlen.reset()
 *         self.tlen_fwd.reset()             # <<<<<<<<<<<<<<
 *         self.tlen_rev.reset()
 *         self.tlen_pp.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_fwd), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 822, __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_ERR(0, 822, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":823
 *         self.tlen.reset()
 *         self.tlen_fwd.reset()
 *         self.tlen_rev.reset()             # <<<<<<<<<<<<<<
 *         self.tlen_pp.reset()
 *         self.tlen_pp_fwd.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_rev), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 823, __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_ERR(0, 823, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":824
 *         self.tlen_fwd.reset()
 *         self.tlen_rev.reset()
 *         self.tlen_pp.reset()             # <<<<<<<<<<<<<<
 *         self.tlen_pp_fwd.reset()
 *         self.tlen_pp_rev.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 824, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 824, __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_ERR(0, 824, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":825
 *         self.tlen_rev.reset()
 *         self.tlen_pp.reset()
 *         self.tlen_pp_fwd.reset()             # <<<<<<<<<<<<<<
 *         self.tlen_pp_rev.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp_fwd), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 825, __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_ERR(0, 825, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":826
 *         self.tlen_pp.reset()
 *         self.tlen_pp_fwd.reset()
 *         self.tlen_pp_rev.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp_rev), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 826, __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_ERR(0, 826, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":817
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = 0
 *         self.reads_fwd = 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_AddTraceback("pysamstats.opt.TlenStrand.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":828
 *         self.tlen_pp_rev.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_10TlenStrand_recv(struct __pyx_obj_10pysamstats_3opt_TlenStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int __pyx_v_is_reverse;
  int __pyx_v_mate_other_chr;
  int64_t __pyx_v_tlen;
  int __pyx_v_mate_is_unmapped;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int32_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":838
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":839
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":840
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_other_chr = <bint>(read.b.core.tid != read.b.core.mtid)
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":841
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)             # <<<<<<<<<<<<<<
 *         mate_other_chr = <bint>(read.b.core.tid != read.b.core.mtid)
 *         tlen = read.b.core.isize
 */
  __pyx_v_mate_is_unmapped = ((__pyx_v_flag & 8) != 0);

  /* "pysamstats/opt.pyx":842
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_other_chr = <bint>(read.b.core.tid != read.b.core.mtid)             # <<<<<<<<<<<<<<
 *         tlen = read.b.core.isize
 * 
 */
  __pyx_v_mate_other_chr = ((__pyx_v_read->b->core.tid != __pyx_v_read->b->core.mtid) != 0);

  /* "pysamstats/opt.pyx":843
 *         mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *         mate_other_chr = <bint>(read.b.core.tid != read.b.core.mtid)
 *         tlen = read.b.core.isize             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_t_2 = __pyx_v_read->b->core.isize;
  __pyx_v_tlen = __pyx_t_2;

  /* "pysamstats/opt.pyx":846
 * 
 *         # do the counting
 *         self.reads_all += 1             # <<<<<<<<<<<<<<
 *         if is_reverse:
 *             self.reads_rev += 1
 */
  __pyx_v_self->reads_all = (__pyx_v_self->reads_all + 1);

  /* "pysamstats/opt.pyx":847
 *         # do the counting
 *         self.reads_all += 1
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.reads_rev += 1
 *         else:
 */
  __pyx_t_3 = (__pyx_v_is_reverse != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":848
 *         self.reads_all += 1
 *         if is_reverse:
 *             self.reads_rev += 1             # <<<<<<<<<<<<<<
 *         else:
 *             self.reads_fwd += 1
 */
    __pyx_v_self->reads_rev = (__pyx_v_self->reads_rev + 1);

    /* "pysamstats/opt.pyx":847
 *         # do the counting
 *         self.reads_all += 1
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.reads_rev += 1
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":850
 *             self.reads_rev += 1
 *         else:
 *             self.reads_fwd += 1             # <<<<<<<<<<<<<<
 * 
 *         # N.B. insert size is only meaningful if mate is mapped to same chromosome
 */
  /*else*/ {
    __pyx_v_self->reads_fwd = (__pyx_v_self->reads_fwd + 1);
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":853
 * 
 *         # N.B. insert size is only meaningful if mate is mapped to same chromosome
 *         if not mate_is_unmapped and not mate_other_chr:             # <<<<<<<<<<<<<<
 *             self.tlen.update(tlen)
 *             if is_reverse:
 */
  __pyx_t_4 = ((!(__pyx_v_mate_is_unmapped != 0)) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_3 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_4 = ((!(__pyx_v_mate_other_chr != 0)) != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":854
 *         # N.B. insert size is only meaningful if mate is mapped to same chromosome
 *         if not mate_is_unmapped and not mate_other_chr:
 *             self.tlen.update(tlen)             # <<<<<<<<<<<<<<
 *             if is_reverse:
 *                 self.tlen_rev.update(tlen)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *)__pyx_v_self->tlen->__pyx_vtab)->update(__pyx_v_self->tlen, __pyx_v_tlen);

    /* "pysamstats/opt.pyx":855
 *         if not mate_is_unmapped and not mate_other_chr:
 *             self.tlen.update(tlen)
 *             if is_reverse:             # <<<<<<<<<<<<<<
 *                 self.tlen_rev.update(tlen)
 *             else:
 */
    __pyx_t_3 = (__pyx_v_is_reverse != 0);
    if (__pyx_t_3) {

      /* "pysamstats/opt.pyx":856
 *             self.tlen.update(tlen)
 *             if is_reverse:
 *                 self.tlen_rev.update(tlen)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.tlen_fwd.update(tlen)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *)__pyx_v_self->tlen_rev->__pyx_vtab)->update(__pyx_v_self->tlen_rev, __pyx_v_tlen);

      /* "pysamstats/opt.pyx":855
 *         if not mate_is_unmapped and not mate_other_chr:
 *             self.tlen.update(tlen)
 *             if is_reverse:             # <<<<<<<<<<<<<<
 *                 self.tlen_rev.update(tlen)
 *             else:
 */
      goto __pyx_L7;
    }

    /* "pysamstats/opt.pyx":858
 *                 self.tlen_rev.update(tlen)
 *             else:
 *                 self.tlen_fwd.update(tlen)             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.tlen_pp.update(tlen)
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *)__pyx_v_self->tlen_fwd->__pyx_vtab)->update(__pyx_v_self->tlen_fwd, __pyx_v_tlen);
    }
    __pyx_L7:;

    /* "pysamstats/opt.pyx":853
 * 
 *         # N.B. insert size is only meaningful if mate is mapped to same chromosome
 *         if not mate_is_unmapped and not mate_other_chr:             # <<<<<<<<<<<<<<
 *             self.tlen.update(tlen)
 *             if is_reverse:
 */
  }

  /* "pysamstats/opt.pyx":859
 *             else:
 *                 self.tlen_fwd.update(tlen)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.tlen_pp.update(tlen)
 *             if is_reverse:
 */
  __pyx_t_3 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":860
 *                 self.tlen_fwd.update(tlen)
 *         if is_proper_pair:
 *             self.tlen_pp.update(tlen)             # <<<<<<<<<<<<<<
 *             if is_reverse:
 *                 self.tlen_pp_rev.update(tlen)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *)__pyx_v_self->tlen_pp->__pyx_vtab)->update(__pyx_v_self->tlen_pp, __pyx_v_tlen);

    /* "pysamstats/opt.pyx":861
 *         if is_proper_pair:
 *             self.tlen_pp.update(tlen)
 *             if is_reverse:             # <<<<<<<<<<<<<<
 *                 self.tlen_pp_rev.update(tlen)
 *             else:
 */
    __pyx_t_3 = (__pyx_v_is_reverse != 0);
    if (__pyx_t_3) {

      /* "pysamstats/opt.pyx":862
 *             self.tlen_pp.update(tlen)
 *             if is_reverse:
 *                 self.tlen_pp_rev.update(tlen)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.tlen_pp_fwd.update(tlen)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *)__pyx_v_self->tlen_pp_rev->__pyx_vtab)->update(__pyx_v_self->tlen_pp_rev, __pyx_v_tlen);

      /* "pysamstats/opt.pyx":861
 *         if is_proper_pair:
 *             self.tlen_pp.update(tlen)
 *             if is_reverse:             # <<<<<<<<<<<<<<
 *                 self.tlen_pp_rev.update(tlen)
 *             else:
 */
      goto __pyx_L9;
    }

    /* "pysamstats/opt.pyx":864
 *                 self.tlen_pp_rev.update(tlen)
 *             else:
 *                 self.tlen_pp_fwd.update(tlen)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_10pysamstats_3opt_TlenHelper *)__pyx_v_self->tlen_pp_fwd->__pyx_vtab)->update(__pyx_v_self->tlen_pp_fwd, __pyx_v_tlen);
    }
    __pyx_L9:;

    /* "pysamstats/opt.pyx":859
 *             else:
 *                 self.tlen_fwd.update(tlen)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.tlen_pp.update(tlen)
 *             if is_reverse:
 */
  }

  /* "pysamstats/opt.pyx":828
 *         self.tlen_pp_rev.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":866
 *                 self.tlen_pp_fwd.update(tlen)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_10TlenStrand_rec(struct __pyx_obj_10pysamstats_3opt_TlenStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":870
 *         # make record
 *         rec = {
 *             'reads_all': self.reads_all,             # <<<<<<<<<<<<<<
 *             'reads_fwd': self.reads_fwd,
 *             'reads_rev': self.reads_rev,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":871
 *         rec = {
 *             'reads_all': self.reads_all,
 *             'reads_fwd': self.reads_fwd,             # <<<<<<<<<<<<<<
 *             'reads_rev': self.reads_rev,
 *             'reads_paired': self.tlen.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_fwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 871, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":872
 *             'reads_all': self.reads_all,
 *             'reads_fwd': self.reads_fwd,
 *             'reads_rev': self.reads_rev,             # <<<<<<<<<<<<<<
 *             'reads_paired': self.tlen.n,
 *             'reads_paired_fwd': self.tlen_fwd.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_rev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 872, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":873
 *             'reads_fwd': self.reads_fwd,
 *             'reads_rev': self.reads_rev,
 *             'reads_paired': self.tlen.n,             # <<<<<<<<<<<<<<
 *             'reads_paired_fwd': self.tlen_fwd.n,
 *             'reads_paired_rev': self.tlen_rev.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->tlen->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 873, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_paired, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":874
 *             'reads_rev': self.reads_rev,
 *             'reads_paired': self.tlen.n,
 *             'reads_paired_fwd': self.tlen_fwd.n,             # <<<<<<<<<<<<<<
 *             'reads_paired_rev': self.tlen_rev.n,
 *             'reads_pp': self.tlen_pp.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->tlen_fwd->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 874, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_paired_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":875
 *             'reads_paired': self.tlen.n,
 *             'reads_paired_fwd': self.tlen_fwd.n,
 *             'reads_paired_rev': self.tlen_rev.n,             # <<<<<<<<<<<<<<
 *             'reads_pp': self.tlen_pp.n,
 *             'reads_pp_fwd': self.tlen_pp_fwd.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->tlen_rev->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 875, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_paired_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":876
 *             'reads_paired_fwd': self.tlen_fwd.n,
 *             'reads_paired_rev': self.tlen_rev.n,
 *             'reads_pp': self.tlen_pp.n,             # <<<<<<<<<<<<<<
 *             'reads_pp_fwd': self.tlen_pp_fwd.n,
 *             'reads_pp_rev': self.tlen_pp_rev.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->tlen_pp->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":877
 *             'reads_paired_rev': self.tlen_rev.n,
 *             'reads_pp': self.tlen_pp.n,
 *             'reads_pp_fwd': self.tlen_pp_fwd.n,             # <<<<<<<<<<<<<<
 *             'reads_pp_rev': self.tlen_pp_rev.n,
 *             'mean_tlen': self.tlen.mean(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->tlen_pp_fwd->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 877, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":878
 *             'reads_pp': self.tlen_pp.n,
 *             'reads_pp_fwd': self.tlen_pp_fwd.n,
 *             'reads_pp_rev': self.tlen_pp_rev.n,             # <<<<<<<<<<<<<<
 *             'mean_tlen': self.tlen.mean(),
 *             'mean_tlen_fwd': self.tlen_fwd.mean(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_self->tlen_pp_rev->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 878, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":879
 *             'reads_pp_fwd': self.tlen_pp_fwd.n,
 *             'reads_pp_rev': self.tlen_pp_rev.n,
 *             'mean_tlen': self.tlen.mean(),             # <<<<<<<<<<<<<<
 *             'mean_tlen_fwd': self.tlen_fwd.mean(),
 *             'mean_tlen_rev': self.tlen_rev.mean(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 879, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 879, __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_ERR(0, 879, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":880
 *             'reads_pp_rev': self.tlen_pp_rev.n,
 *             'mean_tlen': self.tlen.mean(),
 *             'mean_tlen_fwd': self.tlen_fwd.mean(),             # <<<<<<<<<<<<<<
 *             'mean_tlen_rev': self.tlen_rev.mean(),
 *             'mean_tlen_pp': self.tlen_pp.mean(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_fwd), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 880, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 880, __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_ERR(0, 880, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":881
 *             'mean_tlen': self.tlen.mean(),
 *             'mean_tlen_fwd': self.tlen_fwd.mean(),
 *             'mean_tlen_rev': self.tlen_rev.mean(),             # <<<<<<<<<<<<<<
 *             'mean_tlen_pp': self.tlen_pp.mean(),
 *             'mean_tlen_pp_fwd': self.tlen_pp_fwd.mean(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_rev), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 881, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 881, __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_ERR(0, 881, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":882
 *             'mean_tlen_fwd': self.tlen_fwd.mean(),
 *             'mean_tlen_rev': self.tlen_rev.mean(),
 *             'mean_tlen_pp': self.tlen_pp.mean(),             # <<<<<<<<<<<<<<
 *             'mean_tlen_pp_fwd': self.tlen_pp_fwd.mean(),
 *             'mean_tlen_pp_rev': self.tlen_pp_rev.mean(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 882, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 882, __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_ERR(0, 882, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen_pp, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":883
 *             'mean_tlen_rev': self.tlen_rev.mean(),
 *             'mean_tlen_pp': self.tlen_pp.mean(),
 *             'mean_tlen_pp_fwd': self.tlen_pp_fwd.mean(),             # <<<<<<<<<<<<<<
 *             'mean_tlen_pp_rev': self.tlen_pp_rev.mean(),
 *             'rms_tlen': self.tlen.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp_fwd), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 883, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 883, __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_ERR(0, 883, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":884
 *             'mean_tlen_pp': self.tlen_pp.mean(),
 *             'mean_tlen_pp_fwd': self.tlen_pp_fwd.mean(),
 *             'mean_tlen_pp_rev': self.tlen_pp_rev.mean(),             # <<<<<<<<<<<<<<
 *             'rms_tlen': self.tlen.rms(),
 *             'rms_tlen_fwd': self.tlen_fwd.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp_rev), __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 884, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 884, __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_ERR(0, 884, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":885
 *             'mean_tlen_pp_fwd': self.tlen_pp_fwd.mean(),
 *             'mean_tlen_pp_rev': self.tlen_pp_rev.mean(),
 *             'rms_tlen': self.tlen.rms(),             # <<<<<<<<<<<<<<
 *             'rms_tlen_fwd': self.tlen_fwd.rms(),
 *             'rms_tlen_rev': self.tlen_rev.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 885, __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_ERR(0, 885, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":886
 *             'mean_tlen_pp_rev': self.tlen_pp_rev.mean(),
 *             'rms_tlen': self.tlen.rms(),
 *             'rms_tlen_fwd': self.tlen_fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_tlen_rev': self.tlen_rev.rms(),
 *             'rms_tlen_pp': self.tlen_pp.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 886, __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_ERR(0, 886, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":887
 *             'rms_tlen': self.tlen.rms(),
 *             'rms_tlen_fwd': self.tlen_fwd.rms(),
 *             'rms_tlen_rev': self.tlen_rev.rms(),             # <<<<<<<<<<<<<<
 *             'rms_tlen_pp': self.tlen_pp.rms(),
 *             'rms_tlen_pp_fwd': self.tlen_pp_fwd.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 887, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 887, __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_ERR(0, 887, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":888
 *             'rms_tlen_fwd': self.tlen_fwd.rms(),
 *             'rms_tlen_rev': self.tlen_rev.rms(),
 *             'rms_tlen_pp': self.tlen_pp.rms(),             # <<<<<<<<<<<<<<
 *             'rms_tlen_pp_fwd': self.tlen_pp_fwd.rms(),
 *             'rms_tlen_pp_rev': self.tlen_pp_rev.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 888, __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_ERR(0, 888, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen_pp, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":889
 *             'rms_tlen_rev': self.tlen_rev.rms(),
 *             'rms_tlen_pp': self.tlen_pp.rms(),
 *             'rms_tlen_pp_fwd': self.tlen_pp_fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_tlen_pp_rev': self.tlen_pp_rev.rms(),
 *             'std_tlen': self.tlen.std(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp_fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 889, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 889, __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_ERR(0, 889, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":890
 *             'rms_tlen_pp': self.tlen_pp.rms(),
 *             'rms_tlen_pp_fwd': self.tlen_pp_fwd.rms(),
 *             'rms_tlen_pp_rev': self.tlen_pp_rev.rms(),             # <<<<<<<<<<<<<<
 *             'std_tlen': self.tlen.std(),
 *             'std_tlen_fwd': self.tlen_fwd.std(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp_rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 890, __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_ERR(0, 890, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":891
 *             'rms_tlen_pp_fwd': self.tlen_pp_fwd.rms(),
 *             'rms_tlen_pp_rev': self.tlen_pp_rev.rms(),
 *             'std_tlen': self.tlen.std(),             # <<<<<<<<<<<<<<
 *             'std_tlen_fwd': self.tlen_fwd.std(),
 *             'std_tlen_rev': self.tlen_rev.std(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen), __pyx_n_s_std); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 891, __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_ERR(0, 891, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_std_tlen, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":892
 *             'rms_tlen_pp_rev': self.tlen_pp_rev.rms(),
 *             'std_tlen': self.tlen.std(),
 *             'std_tlen_fwd': self.tlen_fwd.std(),             # <<<<<<<<<<<<<<
 *             'std_tlen_rev': self.tlen_rev.std(),
 *             'std_tlen_pp': self.tlen_pp.std(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_fwd), __pyx_n_s_std); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 892, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 892, __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_ERR(0, 892, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_std_tlen_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":893
 *             'std_tlen': self.tlen.std(),
 *             'std_tlen_fwd': self.tlen_fwd.std(),
 *             'std_tlen_rev': self.tlen_rev.std(),             # <<<<<<<<<<<<<<
 *             'std_tlen_pp': self.tlen_pp.std(),
 *             'std_tlen_pp_fwd': self.tlen_pp_fwd.std(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_rev), __pyx_n_s_std); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 893, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 893, __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_ERR(0, 893, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_std_tlen_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":894
 *             'std_tlen_fwd': self.tlen_fwd.std(),
 *             'std_tlen_rev': self.tlen_rev.std(),
 *             'std_tlen_pp': self.tlen_pp.std(),             # <<<<<<<<<<<<<<
 *             'std_tlen_pp_fwd': self.tlen_pp_fwd.std(),
 *             'std_tlen_pp_rev': self.tlen_pp_rev.std(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp), __pyx_n_s_std); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 894, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 894, __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_ERR(0, 894, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_std_tlen_pp, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":895
 *             'std_tlen_rev': self.tlen_rev.std(),
 *             'std_tlen_pp': self.tlen_pp.std(),
 *             'std_tlen_pp_fwd': self.tlen_pp_fwd.std(),             # <<<<<<<<<<<<<<
 *             'std_tlen_pp_rev': self.tlen_pp_rev.std(),
 *         }
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp_fwd), __pyx_n_s_std); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 895, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 895, __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_ERR(0, 895, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_std_tlen_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":896
 *             'std_tlen_pp': self.tlen_pp.std(),
 *             'std_tlen_pp_fwd': self.tlen_pp_fwd.std(),
 *             'std_tlen_pp_rev': self.tlen_pp_rev.std(),             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->tlen_pp_rev), __pyx_n_s_std); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 896, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 896, __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_ERR(0, 896, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_std_tlen_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":900
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 900, __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_ERR(0, 900, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":902
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":866
 *                 self.tlen_pp_fwd.update(tlen)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* 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("pysamstats.opt.TlenStrand.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":918
 *         uint64_t sqsum
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_10MapqHelper___init__(struct __pyx_obj_10pysamstats_3opt_MapqHelper *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":919
 * 
 *     def __init__(self):
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 919, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 919, __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_ERR(0, 919, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":918
 *         uint64_t sqsum
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

  /* 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("pysamstats.opt.MapqHelper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":921
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.n = 0
 *         self.nz = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10MapqHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10MapqHelper_2reset[] = "MapqHelper.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10MapqHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10MapqHelper_2reset(((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10MapqHelper_2reset(struct __pyx_obj_10pysamstats_3opt_MapqHelper *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":922
 * 
 *     def reset(self):
 *         self.n = 0             # <<<<<<<<<<<<<<
 *         self.nz = 0
 *         self.max = 0
 */
  __pyx_v_self->n = 0;

  /* "pysamstats/opt.pyx":923
 *     def reset(self):
 *         self.n = 0
 *         self.nz = 0             # <<<<<<<<<<<<<<
 *         self.max = 0
 *         self.sqsum = 0
 */
  __pyx_v_self->nz = 0;

  /* "pysamstats/opt.pyx":924
 *         self.n = 0
 *         self.nz = 0
 *         self.max = 0             # <<<<<<<<<<<<<<
 *         self.sqsum = 0
 * 
 */
  __pyx_v_self->max = 0;

  /* "pysamstats/opt.pyx":925
 *         self.nz = 0
 *         self.max = 0
 *         self.sqsum = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void update(self, uint64_t mapq):
 */
  __pyx_v_self->sqsum = 0;

  /* "pysamstats/opt.pyx":921
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.n = 0
 *         self.nz = 0
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":927
 *         self.sqsum = 0
 * 
 *     cdef void update(self, uint64_t mapq):             # <<<<<<<<<<<<<<
 *         self.n += 1
 *         if mapq == 0:
 */

static void __pyx_f_10pysamstats_3opt_10MapqHelper_update(struct __pyx_obj_10pysamstats_3opt_MapqHelper *__pyx_v_self, uint64_t __pyx_v_mapq) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("update", 0);

  /* "pysamstats/opt.pyx":928
 * 
 *     cdef void update(self, uint64_t mapq):
 *         self.n += 1             # <<<<<<<<<<<<<<
 *         if mapq == 0:
 *             self.nz += 1
 */
  __pyx_v_self->n = (__pyx_v_self->n + 1);

  /* "pysamstats/opt.pyx":929
 *     cdef void update(self, uint64_t mapq):
 *         self.n += 1
 *         if mapq == 0:             # <<<<<<<<<<<<<<
 *             self.nz += 1
 *         if mapq > self.max:
 */
  __pyx_t_1 = ((__pyx_v_mapq == 0) != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":930
 *         self.n += 1
 *         if mapq == 0:
 *             self.nz += 1             # <<<<<<<<<<<<<<
 *         if mapq > self.max:
 *             self.max = mapq
 */
    __pyx_v_self->nz = (__pyx_v_self->nz + 1);

    /* "pysamstats/opt.pyx":929
 *     cdef void update(self, uint64_t mapq):
 *         self.n += 1
 *         if mapq == 0:             # <<<<<<<<<<<<<<
 *             self.nz += 1
 *         if mapq > self.max:
 */
  }

  /* "pysamstats/opt.pyx":931
 *         if mapq == 0:
 *             self.nz += 1
 *         if mapq > self.max:             # <<<<<<<<<<<<<<
 *             self.max = mapq
 *         self.sqsum += mapq**2
 */
  __pyx_t_1 = ((__pyx_v_mapq > __pyx_v_self->max) != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":932
 *             self.nz += 1
 *         if mapq > self.max:
 *             self.max = mapq             # <<<<<<<<<<<<<<
 *         self.sqsum += mapq**2
 * 
 */
    __pyx_v_self->max = __pyx_v_mapq;

    /* "pysamstats/opt.pyx":931
 *         if mapq == 0:
 *             self.nz += 1
 *         if mapq > self.max:             # <<<<<<<<<<<<<<
 *             self.max = mapq
 *         self.sqsum += mapq**2
 */
  }

  /* "pysamstats/opt.pyx":933
 *         if mapq > self.max:
 *             self.max = mapq
 *         self.sqsum += mapq**2             # <<<<<<<<<<<<<<
 * 
 *     def rms(self):
 */
  __pyx_v_self->sqsum = (__pyx_v_self->sqsum + __Pyx_pow_uint64_t(__pyx_v_mapq, 2));

  /* "pysamstats/opt.pyx":927
 *         self.sqsum = 0
 * 
 *     cdef void update(self, uint64_t mapq):             # <<<<<<<<<<<<<<
 *         self.n += 1
 *         if mapq == 0:
 */

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

/* "pysamstats/opt.pyx":935
 *         self.sqsum += mapq**2
 * 
 *     def rms(self):             # <<<<<<<<<<<<<<
 *         return rootmean(self.sqsum, self.n)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10MapqHelper_5rms(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10MapqHelper_4rms[] = "MapqHelper.rms(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10MapqHelper_5rms(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rms (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10MapqHelper_4rms(((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10MapqHelper_4rms(struct __pyx_obj_10pysamstats_3opt_MapqHelper *__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_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("rms", 0);

  /* "pysamstats/opt.pyx":936
 * 
 *     def rms(self):
 *         return rootmean(self.sqsum, self.n)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_rootmean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->sqsum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 936, __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_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":935
 *         self.sqsum += mapq**2
 * 
 *     def rms(self):             # <<<<<<<<<<<<<<
 *         return rootmean(self.sqsum, self.n)
 * 
 */

  /* 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_7);
  __Pyx_AddTraceback("pysamstats.opt.MapqHelper.rms", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":946
 *         MapqHelper pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = MapqHelper()
 *         self.pp = MapqHelper()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_4Mapq___init__(struct __pyx_obj_10pysamstats_3opt_Mapq *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":947
 * 
 *     def __init__(self):
 *         self.all = MapqHelper()             # <<<<<<<<<<<<<<
 *         self.pp = MapqHelper()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_MapqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 947, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->all);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->all));
  __pyx_v_self->all = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":948
 *     def __init__(self):
 *         self.all = MapqHelper()
 *         self.pp = MapqHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_MapqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 948, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp));
  __pyx_v_self->pp = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":949
 *         self.all = MapqHelper()
 *         self.pp = MapqHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 949, __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_ERR(0, 949, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":946
 *         MapqHelper pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = MapqHelper()
 *         self.pp = MapqHelper()
 */

  /* 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("pysamstats.opt.Mapq.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":951
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.pp.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_4Mapq_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_4Mapq_2reset[] = "Mapq.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_4Mapq_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_4Mapq_2reset(((struct __pyx_obj_10pysamstats_3opt_Mapq *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_4Mapq_2reset(struct __pyx_obj_10pysamstats_3opt_Mapq *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":952
 * 
 *     def reset(self):
 *         self.all.reset()             # <<<<<<<<<<<<<<
 *         self.pp.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 952, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 952, __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_ERR(0, 952, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":953
 *     def reset(self):
 *         self.all.reset()
 *         self.pp.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 953, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 953, __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_ERR(0, 953, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":951
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.pp.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.Mapq.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":955
 *         self.pp.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_4Mapq_recv(struct __pyx_obj_10pysamstats_3opt_Mapq *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  uint64_t __pyx_v_mapq;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  uint8_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":963
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 * 
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":964
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":967
 * 
 *         # do the counting
 *         mapq = read.b.core.qual             # <<<<<<<<<<<<<<
 *         self.all.update(mapq)
 *         if is_proper_pair:
 */
  __pyx_t_2 = __pyx_v_read->b->core.qual;
  __pyx_v_mapq = __pyx_t_2;

  /* "pysamstats/opt.pyx":968
 *         # do the counting
 *         mapq = read.b.core.qual
 *         self.all.update(mapq)             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.pp.update(mapq)
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *)__pyx_v_self->all->__pyx_vtab)->update(__pyx_v_self->all, __pyx_v_mapq);

  /* "pysamstats/opt.pyx":969
 *         mapq = read.b.core.qual
 *         self.all.update(mapq)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.update(mapq)
 * 
 */
  __pyx_t_3 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":970
 *         self.all.update(mapq)
 *         if is_proper_pair:
 *             self.pp.update(mapq)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *)__pyx_v_self->pp->__pyx_vtab)->update(__pyx_v_self->pp, __pyx_v_mapq);

    /* "pysamstats/opt.pyx":969
 *         mapq = read.b.core.qual
 *         self.all.update(mapq)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.update(mapq)
 * 
 */
  }

  /* "pysamstats/opt.pyx":955
 *         self.pp.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":972
 *             self.pp.update(mapq)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_4Mapq_rec(struct __pyx_obj_10pysamstats_3opt_Mapq *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":975
 * 
 *         # make record
 *         rec = {'reads_all': self.all.n,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.pp.n,
 *                'reads_mapq0': self.all.nz,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->all->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":976
 *         # make record
 *         rec = {'reads_all': self.all.n,
 *                'reads_pp': self.pp.n,             # <<<<<<<<<<<<<<
 *                'reads_mapq0': self.all.nz,
 *                'reads_mapq0_pp': self.pp.nz,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 976, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":977
 *         rec = {'reads_all': self.all.n,
 *                'reads_pp': self.pp.n,
 *                'reads_mapq0': self.all.nz,             # <<<<<<<<<<<<<<
 *                'reads_mapq0_pp': self.pp.nz,
 *                'rms_mapq': self.all.rms(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->all->nz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0, __pyx_t_2) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":978
 *                'reads_pp': self.pp.n,
 *                'reads_mapq0': self.all.nz,
 *                'reads_mapq0_pp': self.pp.nz,             # <<<<<<<<<<<<<<
 *                'rms_mapq': self.all.rms(),
 *                'rms_mapq_pp': self.pp.rms(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp->nz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0_pp, __pyx_t_2) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":979
 *                'reads_mapq0': self.all.nz,
 *                'reads_mapq0_pp': self.pp.nz,
 *                'rms_mapq': self.all.rms(),             # <<<<<<<<<<<<<<
 *                'rms_mapq_pp': self.pp.rms(),
 *                'max_mapq': self.all.max,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 979, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 979, __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_ERR(0, 979, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq, __pyx_t_2) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":980
 *                'reads_mapq0_pp': self.pp.nz,
 *                'rms_mapq': self.all.rms(),
 *                'rms_mapq_pp': self.pp.rms(),             # <<<<<<<<<<<<<<
 *                'max_mapq': self.all.max,
 *                'max_mapq_pp': self.pp.max}
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 980, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 980, __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_ERR(0, 980, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq_pp, __pyx_t_2) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":981
 *                'rms_mapq': self.all.rms(),
 *                'rms_mapq_pp': self.pp.rms(),
 *                'max_mapq': self.all.max,             # <<<<<<<<<<<<<<
 *                'max_mapq_pp': self.pp.max}
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->all->max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_mapq, __pyx_t_2) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":982
 *                'rms_mapq_pp': self.pp.rms(),
 *                'max_mapq': self.all.max,
 *                'max_mapq_pp': self.pp.max}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->pp->max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 982, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_mapq_pp, __pyx_t_2) < 0) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":985
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 985, __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_ERR(0, 985, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":987
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":972
 *             self.pp.update(mapq)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* 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("pysamstats.opt.Mapq.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1006
 *         MapqHelper pp_rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = MapqHelper()
 *         self.fwd = MapqHelper()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_10MapqStrand___init__(struct __pyx_obj_10pysamstats_3opt_MapqStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1007
 * 
 *     def __init__(self):
 *         self.all = MapqHelper()             # <<<<<<<<<<<<<<
 *         self.fwd = MapqHelper()
 *         self.rev = MapqHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_MapqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1007, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->all);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->all));
  __pyx_v_self->all = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1008
 *     def __init__(self):
 *         self.all = MapqHelper()
 *         self.fwd = MapqHelper()             # <<<<<<<<<<<<<<
 *         self.rev = MapqHelper()
 *         self.pp = MapqHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_MapqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1008, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->fwd);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->fwd));
  __pyx_v_self->fwd = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1009
 *         self.all = MapqHelper()
 *         self.fwd = MapqHelper()
 *         self.rev = MapqHelper()             # <<<<<<<<<<<<<<
 *         self.pp = MapqHelper()
 *         self.pp_fwd = MapqHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_MapqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1009, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->rev);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->rev));
  __pyx_v_self->rev = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1010
 *         self.fwd = MapqHelper()
 *         self.rev = MapqHelper()
 *         self.pp = MapqHelper()             # <<<<<<<<<<<<<<
 *         self.pp_fwd = MapqHelper()
 *         self.pp_rev = MapqHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_MapqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1010, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp));
  __pyx_v_self->pp = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1011
 *         self.rev = MapqHelper()
 *         self.pp = MapqHelper()
 *         self.pp_fwd = MapqHelper()             # <<<<<<<<<<<<<<
 *         self.pp_rev = MapqHelper()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_MapqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1011, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp_fwd);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp_fwd));
  __pyx_v_self->pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1012
 *         self.pp = MapqHelper()
 *         self.pp_fwd = MapqHelper()
 *         self.pp_rev = MapqHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_MapqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1012, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp_rev);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp_rev));
  __pyx_v_self->pp_rev = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1013
 *         self.pp_fwd = MapqHelper()
 *         self.pp_rev = MapqHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1013, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1013, __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_ERR(0, 1013, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1006
 *         MapqHelper pp_rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = MapqHelper()
 *         self.fwd = MapqHelper()
 */

  /* 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("pysamstats.opt.MapqStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1015
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.fwd.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10MapqStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10MapqStrand_2reset[] = "MapqStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10MapqStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10MapqStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_MapqStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10MapqStrand_2reset(struct __pyx_obj_10pysamstats_3opt_MapqStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1016
 * 
 *     def reset(self):
 *         self.all.reset()             # <<<<<<<<<<<<<<
 *         self.fwd.reset()
 *         self.rev.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1016, __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_ERR(0, 1016, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1017
 *     def reset(self):
 *         self.all.reset()
 *         self.fwd.reset()             # <<<<<<<<<<<<<<
 *         self.rev.reset()
 *         self.pp.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->fwd), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1017, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1017, __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_ERR(0, 1017, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1018
 *         self.all.reset()
 *         self.fwd.reset()
 *         self.rev.reset()             # <<<<<<<<<<<<<<
 *         self.pp.reset()
 *         self.pp_fwd.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->rev), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1018, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1018, __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_ERR(0, 1018, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1019
 *         self.fwd.reset()
 *         self.rev.reset()
 *         self.pp.reset()             # <<<<<<<<<<<<<<
 *         self.pp_fwd.reset()
 *         self.pp_rev.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1019, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1019, __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_ERR(0, 1019, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1020
 *         self.rev.reset()
 *         self.pp.reset()
 *         self.pp_fwd.reset()             # <<<<<<<<<<<<<<
 *         self.pp_rev.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp_fwd), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1020, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1020, __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_ERR(0, 1020, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1021
 *         self.pp.reset()
 *         self.pp_fwd.reset()
 *         self.pp_rev.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp_rev), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1021, __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_ERR(0, 1021, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1015
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.fwd.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.MapqStrand.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1023
 *         self.pp_rev.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_10MapqStrand_recv(struct __pyx_obj_10pysamstats_3opt_MapqStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int __pyx_v_is_reverse;
  uint64_t __pyx_v_mapq;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  uint8_t __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1032
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1033
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 * 
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":1034
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":1037
 * 
 *         # do the counting
 *         mapq = read.b.core.qual             # <<<<<<<<<<<<<<
 *         self.all.update(mapq)
 *         if is_reverse:
 */
  __pyx_t_2 = __pyx_v_read->b->core.qual;
  __pyx_v_mapq = __pyx_t_2;

  /* "pysamstats/opt.pyx":1038
 *         # do the counting
 *         mapq = read.b.core.qual
 *         self.all.update(mapq)             # <<<<<<<<<<<<<<
 *         if is_reverse:
 *             self.rev.update(mapq)
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *)__pyx_v_self->all->__pyx_vtab)->update(__pyx_v_self->all, __pyx_v_mapq);

  /* "pysamstats/opt.pyx":1039
 *         mapq = read.b.core.qual
 *         self.all.update(mapq)
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.rev.update(mapq)
 *         else:
 */
  __pyx_t_3 = (__pyx_v_is_reverse != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":1040
 *         self.all.update(mapq)
 *         if is_reverse:
 *             self.rev.update(mapq)             # <<<<<<<<<<<<<<
 *         else:
 *             self.fwd.update(mapq)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *)__pyx_v_self->rev->__pyx_vtab)->update(__pyx_v_self->rev, __pyx_v_mapq);

    /* "pysamstats/opt.pyx":1039
 *         mapq = read.b.core.qual
 *         self.all.update(mapq)
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.rev.update(mapq)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":1042
 *             self.rev.update(mapq)
 *         else:
 *             self.fwd.update(mapq)             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.pp.update(mapq)
 */
  /*else*/ {
    ((struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *)__pyx_v_self->fwd->__pyx_vtab)->update(__pyx_v_self->fwd, __pyx_v_mapq);
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":1043
 *         else:
 *             self.fwd.update(mapq)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.update(mapq)
 *             if is_reverse:
 */
  __pyx_t_3 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":1044
 *             self.fwd.update(mapq)
 *         if is_proper_pair:
 *             self.pp.update(mapq)             # <<<<<<<<<<<<<<
 *             if is_reverse:
 *                 self.pp_rev.update(mapq)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *)__pyx_v_self->pp->__pyx_vtab)->update(__pyx_v_self->pp, __pyx_v_mapq);

    /* "pysamstats/opt.pyx":1045
 *         if is_proper_pair:
 *             self.pp.update(mapq)
 *             if is_reverse:             # <<<<<<<<<<<<<<
 *                 self.pp_rev.update(mapq)
 *             else:
 */
    __pyx_t_3 = (__pyx_v_is_reverse != 0);
    if (__pyx_t_3) {

      /* "pysamstats/opt.pyx":1046
 *             self.pp.update(mapq)
 *             if is_reverse:
 *                 self.pp_rev.update(mapq)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.pp_fwd.update(mapq)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *)__pyx_v_self->pp_rev->__pyx_vtab)->update(__pyx_v_self->pp_rev, __pyx_v_mapq);

      /* "pysamstats/opt.pyx":1045
 *         if is_proper_pair:
 *             self.pp.update(mapq)
 *             if is_reverse:             # <<<<<<<<<<<<<<
 *                 self.pp_rev.update(mapq)
 *             else:
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":1048
 *                 self.pp_rev.update(mapq)
 *             else:
 *                 self.pp_fwd.update(mapq)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_10pysamstats_3opt_MapqHelper *)__pyx_v_self->pp_fwd->__pyx_vtab)->update(__pyx_v_self->pp_fwd, __pyx_v_mapq);
    }
    __pyx_L5:;

    /* "pysamstats/opt.pyx":1043
 *         else:
 *             self.fwd.update(mapq)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.update(mapq)
 *             if is_reverse:
 */
  }

  /* "pysamstats/opt.pyx":1023
 *         self.pp_rev.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":1050
 *                 self.pp_fwd.update(mapq)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_10MapqStrand_rec(struct __pyx_obj_10pysamstats_3opt_MapqStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1054
 *         # make record
 *         rec = {
 *             'reads_all': self.all.n,             # <<<<<<<<<<<<<<
 *             'reads_fwd': self.fwd.n,
 *             'reads_rev': self.rev.n,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->all->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1055
 *         rec = {
 *             'reads_all': self.all.n,
 *             'reads_fwd': self.fwd.n,             # <<<<<<<<<<<<<<
 *             'reads_rev': self.rev.n,
 *             'reads_pp': self.pp.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->fwd->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1055, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1056
 *             'reads_all': self.all.n,
 *             'reads_fwd': self.fwd.n,
 *             'reads_rev': self.rev.n,             # <<<<<<<<<<<<<<
 *             'reads_pp': self.pp.n,
 *             'reads_pp_fwd': self.pp_fwd.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->rev->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1056, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1057
 *             'reads_fwd': self.fwd.n,
 *             'reads_rev': self.rev.n,
 *             'reads_pp': self.pp.n,             # <<<<<<<<<<<<<<
 *             'reads_pp_fwd': self.pp_fwd.n,
 *             'reads_pp_rev': self.pp_rev.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1057, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1058
 *             'reads_rev': self.rev.n,
 *             'reads_pp': self.pp.n,
 *             'reads_pp_fwd': self.pp_fwd.n,             # <<<<<<<<<<<<<<
 *             'reads_pp_rev': self.pp_rev.n,
 *             'reads_mapq0': self.all.nz,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp_fwd->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1058, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1059
 *             'reads_pp': self.pp.n,
 *             'reads_pp_fwd': self.pp_fwd.n,
 *             'reads_pp_rev': self.pp_rev.n,             # <<<<<<<<<<<<<<
 *             'reads_mapq0': self.all.nz,
 *             'reads_mapq0_fwd': self.fwd.nz,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp_rev->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1059, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1060
 *             'reads_pp_fwd': self.pp_fwd.n,
 *             'reads_pp_rev': self.pp_rev.n,
 *             'reads_mapq0': self.all.nz,             # <<<<<<<<<<<<<<
 *             'reads_mapq0_fwd': self.fwd.nz,
 *             'reads_mapq0_rev': self.rev.nz,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->all->nz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1060, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1061
 *             'reads_pp_rev': self.pp_rev.n,
 *             'reads_mapq0': self.all.nz,
 *             'reads_mapq0_fwd': self.fwd.nz,             # <<<<<<<<<<<<<<
 *             'reads_mapq0_rev': self.rev.nz,
 *             'reads_mapq0_pp': self.pp.nz,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->fwd->nz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1061, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1062
 *             'reads_mapq0': self.all.nz,
 *             'reads_mapq0_fwd': self.fwd.nz,
 *             'reads_mapq0_rev': self.rev.nz,             # <<<<<<<<<<<<<<
 *             'reads_mapq0_pp': self.pp.nz,
 *             'reads_mapq0_pp_fwd': self.pp_fwd.nz,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->rev->nz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1063
 *             'reads_mapq0_fwd': self.fwd.nz,
 *             'reads_mapq0_rev': self.rev.nz,
 *             'reads_mapq0_pp': self.pp.nz,             # <<<<<<<<<<<<<<
 *             'reads_mapq0_pp_fwd': self.pp_fwd.nz,
 *             'reads_mapq0_pp_rev': self.pp_rev.nz,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp->nz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1063, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1064
 *             'reads_mapq0_rev': self.rev.nz,
 *             'reads_mapq0_pp': self.pp.nz,
 *             'reads_mapq0_pp_fwd': self.pp_fwd.nz,             # <<<<<<<<<<<<<<
 *             'reads_mapq0_pp_rev': self.pp_rev.nz,
 *             'rms_mapq': self.all.rms(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp_fwd->nz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1064, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1065
 *             'reads_mapq0_pp': self.pp.nz,
 *             'reads_mapq0_pp_fwd': self.pp_fwd.nz,
 *             'reads_mapq0_pp_rev': self.pp_rev.nz,             # <<<<<<<<<<<<<<
 *             'rms_mapq': self.all.rms(),
 *             'rms_mapq_fwd': self.fwd.rms(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->pp_rev->nz); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1065, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1066
 *             'reads_mapq0_pp_fwd': self.pp_fwd.nz,
 *             'reads_mapq0_pp_rev': self.pp_rev.nz,
 *             'rms_mapq': self.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_mapq_fwd': self.fwd.rms(),
 *             'rms_mapq_rev': self.rev.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1066, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1066, __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_ERR(0, 1066, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1067
 *             'reads_mapq0_pp_rev': self.pp_rev.nz,
 *             'rms_mapq': self.all.rms(),
 *             'rms_mapq_fwd': self.fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_mapq_rev': self.rev.rms(),
 *             'rms_mapq_pp': self.pp.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1067, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1067, __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_ERR(0, 1067, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1068
 *             'rms_mapq': self.all.rms(),
 *             'rms_mapq_fwd': self.fwd.rms(),
 *             'rms_mapq_rev': self.rev.rms(),             # <<<<<<<<<<<<<<
 *             'rms_mapq_pp': self.pp.rms(),
 *             'rms_mapq_pp_fwd': self.pp_fwd.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1068, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1068, __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_ERR(0, 1068, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1069
 *             'rms_mapq_fwd': self.fwd.rms(),
 *             'rms_mapq_rev': self.rev.rms(),
 *             'rms_mapq_pp': self.pp.rms(),             # <<<<<<<<<<<<<<
 *             'rms_mapq_pp_fwd': self.pp_fwd.rms(),
 *             'rms_mapq_pp_rev': self.pp_rev.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1069, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1069, __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_ERR(0, 1069, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1070
 *             'rms_mapq_rev': self.rev.rms(),
 *             'rms_mapq_pp': self.pp.rms(),
 *             'rms_mapq_pp_fwd': self.pp_fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_mapq_pp_rev': self.pp_rev.rms(),
 *             'max_mapq': self.all.max,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp_fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1070, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1070, __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_ERR(0, 1070, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1071
 *             'rms_mapq_pp': self.pp.rms(),
 *             'rms_mapq_pp_fwd': self.pp_fwd.rms(),
 *             'rms_mapq_pp_rev': self.pp_rev.rms(),             # <<<<<<<<<<<<<<
 *             'max_mapq': self.all.max,
 *             'max_mapq_fwd': self.fwd.max,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp_rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1071, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1071, __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_ERR(0, 1071, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1072
 *             'rms_mapq_pp_fwd': self.pp_fwd.rms(),
 *             'rms_mapq_pp_rev': self.pp_rev.rms(),
 *             'max_mapq': self.all.max,             # <<<<<<<<<<<<<<
 *             'max_mapq_fwd': self.fwd.max,
 *             'max_mapq_rev': self.rev.max,
 */
  __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->all->max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_mapq, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1073
 *             'rms_mapq_pp_rev': self.pp_rev.rms(),
 *             'max_mapq': self.all.max,
 *             'max_mapq_fwd': self.fwd.max,             # <<<<<<<<<<<<<<
 *             'max_mapq_rev': self.rev.max,
 *             'max_mapq_pp': self.pp.max,
 */
  __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->fwd->max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_mapq_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1074
 *             'max_mapq': self.all.max,
 *             'max_mapq_fwd': self.fwd.max,
 *             'max_mapq_rev': self.rev.max,             # <<<<<<<<<<<<<<
 *             'max_mapq_pp': self.pp.max,
 *             'max_mapq_pp_fwd': self.pp_fwd.max,
 */
  __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->rev->max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1074, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_mapq_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1075
 *             'max_mapq_fwd': self.fwd.max,
 *             'max_mapq_rev': self.rev.max,
 *             'max_mapq_pp': self.pp.max,             # <<<<<<<<<<<<<<
 *             'max_mapq_pp_fwd': self.pp_fwd.max,
 *             'max_mapq_pp_rev': self.pp_rev.max,
 */
  __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->pp->max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1075, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_mapq_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1076
 *             'max_mapq_rev': self.rev.max,
 *             'max_mapq_pp': self.pp.max,
 *             'max_mapq_pp_fwd': self.pp_fwd.max,             # <<<<<<<<<<<<<<
 *             'max_mapq_pp_rev': self.pp_rev.max,
 *         }
 */
  __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->pp_fwd->max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1076, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_mapq_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1077
 *             'max_mapq_pp': self.pp.max,
 *             'max_mapq_pp_fwd': self.pp_fwd.max,
 *             'max_mapq_pp_rev': self.pp_rev.max,             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->pp_rev->max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1077, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_mapq_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1081
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1081, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1081, __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_ERR(0, 1081, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1083
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1050
 *                 self.pp_fwd.update(mapq)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* 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("pysamstats.opt.MapqStrand.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1099
 *         uint64_t sqsum
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_11BaseqHelper___init__(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1100
 * 
 *     def __init__(self):
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1100, __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_ERR(0, 1100, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1099
 *         uint64_t sqsum
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */

  /* 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("pysamstats.opt.BaseqHelper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1102
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.n = 0
 *         self.n_nodel = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_11BaseqHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_11BaseqHelper_2reset[] = "BaseqHelper.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_11BaseqHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_11BaseqHelper_2reset(((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_11BaseqHelper_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1103
 * 
 *     def reset(self):
 *         self.n = 0             # <<<<<<<<<<<<<<
 *         self.n_nodel = 0
 *         self.sqsum = 0
 */
  __pyx_v_self->n = 0;

  /* "pysamstats/opt.pyx":1104
 *     def reset(self):
 *         self.n = 0
 *         self.n_nodel = 0             # <<<<<<<<<<<<<<
 *         self.sqsum = 0
 * 
 */
  __pyx_v_self->n_nodel = 0;

  /* "pysamstats/opt.pyx":1105
 *         self.n = 0
 *         self.n_nodel = 0
 *         self.sqsum = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef void update(self, int64_t baseq_squared):
 */
  __pyx_v_self->sqsum = 0;

  /* "pysamstats/opt.pyx":1102
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.n = 0
 *         self.n_nodel = 0
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1107
 *         self.sqsum = 0
 * 
 *     cdef void update(self, int64_t baseq_squared):             # <<<<<<<<<<<<<<
 *         self.n += 1
 *         if baseq_squared >= 0:
 */

static void __pyx_f_10pysamstats_3opt_11BaseqHelper_update(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *__pyx_v_self, int64_t __pyx_v_baseq_squared) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("update", 0);

  /* "pysamstats/opt.pyx":1108
 * 
 *     cdef void update(self, int64_t baseq_squared):
 *         self.n += 1             # <<<<<<<<<<<<<<
 *         if baseq_squared >= 0:
 *             self.n_nodel += 1
 */
  __pyx_v_self->n = (__pyx_v_self->n + 1);

  /* "pysamstats/opt.pyx":1109
 *     cdef void update(self, int64_t baseq_squared):
 *         self.n += 1
 *         if baseq_squared >= 0:             # <<<<<<<<<<<<<<
 *             self.n_nodel += 1
 *             self.sqsum += baseq_squared
 */
  __pyx_t_1 = ((__pyx_v_baseq_squared >= 0) != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":1110
 *         self.n += 1
 *         if baseq_squared >= 0:
 *             self.n_nodel += 1             # <<<<<<<<<<<<<<
 *             self.sqsum += baseq_squared
 * 
 */
    __pyx_v_self->n_nodel = (__pyx_v_self->n_nodel + 1);

    /* "pysamstats/opt.pyx":1111
 *         if baseq_squared >= 0:
 *             self.n_nodel += 1
 *             self.sqsum += baseq_squared             # <<<<<<<<<<<<<<
 * 
 *     def rms(self):
 */
    __pyx_v_self->sqsum = (__pyx_v_self->sqsum + __pyx_v_baseq_squared);

    /* "pysamstats/opt.pyx":1109
 *     cdef void update(self, int64_t baseq_squared):
 *         self.n += 1
 *         if baseq_squared >= 0:             # <<<<<<<<<<<<<<
 *             self.n_nodel += 1
 *             self.sqsum += baseq_squared
 */
  }

  /* "pysamstats/opt.pyx":1107
 *         self.sqsum = 0
 * 
 *     cdef void update(self, int64_t baseq_squared):             # <<<<<<<<<<<<<<
 *         self.n += 1
 *         if baseq_squared >= 0:
 */

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

/* "pysamstats/opt.pyx":1113
 *             self.sqsum += baseq_squared
 * 
 *     def rms(self):             # <<<<<<<<<<<<<<
 *         return rootmean(self.sqsum, self.n_nodel)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_11BaseqHelper_5rms(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_11BaseqHelper_4rms[] = "BaseqHelper.rms(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_11BaseqHelper_5rms(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rms (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_11BaseqHelper_4rms(((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_11BaseqHelper_4rms(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *__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_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("rms", 0);

  /* "pysamstats/opt.pyx":1114
 * 
 *     def rms(self):
 *         return rootmean(self.sqsum, self.n_nodel)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_rootmean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->sqsum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->n_nodel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1114, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1114, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1114, __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_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1113
 *             self.sqsum += baseq_squared
 * 
 *     def rms(self):             # <<<<<<<<<<<<<<
 *         return rootmean(self.sqsum, self.n_nodel)
 * 
 */

  /* 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_7);
  __Pyx_AddTraceback("pysamstats.opt.BaseqHelper.rms", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1124
 *         BaseqHelper pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = BaseqHelper()
 *         self.pp = BaseqHelper()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_13BaseqPpHelper___init__(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1125
 * 
 *     def __init__(self):
 *         self.all = BaseqHelper()             # <<<<<<<<<<<<<<
 *         self.pp = BaseqHelper()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->all);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->all));
  __pyx_v_self->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1126
 *     def __init__(self):
 *         self.all = BaseqHelper()
 *         self.pp = BaseqHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp));
  __pyx_v_self->pp = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1127
 *         self.all = BaseqHelper()
 *         self.pp = BaseqHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1127, __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_ERR(0, 1127, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1124
 *         BaseqHelper pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = BaseqHelper()
 *         self.pp = BaseqHelper()
 */

  /* 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("pysamstats.opt.BaseqPpHelper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1129
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.pp.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_13BaseqPpHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_13BaseqPpHelper_2reset[] = "BaseqPpHelper.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_13BaseqPpHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_13BaseqPpHelper_2reset(((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_13BaseqPpHelper_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1130
 * 
 *     def reset(self):
 *         self.all.reset()             # <<<<<<<<<<<<<<
 *         self.pp.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1130, __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_ERR(0, 1130, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1131
 *     def reset(self):
 *         self.all.reset()
 *         self.pp.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1131, __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_ERR(0, 1131, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1129
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.pp.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.BaseqPpHelper.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1133
 *         self.pp.reset()
 * 
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair):             # <<<<<<<<<<<<<<
 *         self.all.update(baseq_squared)
 *         if is_proper_pair:
 */

static void __pyx_f_10pysamstats_3opt_13BaseqPpHelper_update(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *__pyx_v_self, int64_t __pyx_v_baseq_squared, int __pyx_v_is_proper_pair) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("update", 0);

  /* "pysamstats/opt.pyx":1134
 * 
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair):
 *         self.all.update(baseq_squared)             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.pp.update(baseq_squared)
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *)__pyx_v_self->all->__pyx_vtab)->update(__pyx_v_self->all, __pyx_v_baseq_squared);

  /* "pysamstats/opt.pyx":1135
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair):
 *         self.all.update(baseq_squared)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.update(baseq_squared)
 * 
 */
  __pyx_t_1 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":1136
 *         self.all.update(baseq_squared)
 *         if is_proper_pair:
 *             self.pp.update(baseq_squared)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *)__pyx_v_self->pp->__pyx_vtab)->update(__pyx_v_self->pp, __pyx_v_baseq_squared);

    /* "pysamstats/opt.pyx":1135
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair):
 *         self.all.update(baseq_squared)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.update(baseq_squared)
 * 
 */
  }

  /* "pysamstats/opt.pyx":1133
 *         self.pp.reset()
 * 
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair):             # <<<<<<<<<<<<<<
 *         self.all.update(baseq_squared)
 *         if is_proper_pair:
 */

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

/* "pysamstats/opt.pyx":1145
 *         BaseqPpHelper helper
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.helper = BaseqPpHelper()
 *         self.reset()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_5Baseq___init__(struct __pyx_obj_10pysamstats_3opt_Baseq *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1146
 * 
 *     def __init__(self):
 *         self.helper = BaseqPpHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqPpHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->helper);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->helper));
  __pyx_v_self->helper = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1147
 *     def __init__(self):
 *         self.helper = BaseqPpHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1147, __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_ERR(0, 1147, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1145
 *         BaseqPpHelper helper
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.helper = BaseqPpHelper()
 *         self.reset()
 */

  /* 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("pysamstats.opt.Baseq.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1149
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.helper.reset()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_5Baseq_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_5Baseq_2reset[] = "Baseq.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_5Baseq_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_5Baseq_2reset(((struct __pyx_obj_10pysamstats_3opt_Baseq *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_5Baseq_2reset(struct __pyx_obj_10pysamstats_3opt_Baseq *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1150
 * 
 *     def reset(self):
 *         self.helper.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1150, __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_ERR(0, 1150, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1149
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.helper.reset()
 * 
 */

  /* 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_AddTraceback("pysamstats.opt.Baseq.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1152
 *         self.helper.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_5Baseq_recv(struct __pyx_obj_10pysamstats_3opt_Baseq *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int64_t __pyx_v_baseq;
  int64_t __pyx_v_baseq_squared;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1156
 *             uint32_t flag
 *             bint is_proper_pair
 *             int64_t baseq = -1             # <<<<<<<<<<<<<<
 *             int64_t baseq_squared = -1
 * 
 */
  __pyx_v_baseq = -1L;

  /* "pysamstats/opt.pyx":1157
 *             bint is_proper_pair
 *             int64_t baseq = -1
 *             int64_t baseq_squared = -1             # <<<<<<<<<<<<<<
 * 
 *         # convenience variables
 */
  __pyx_v_baseq_squared = -1L;

  /* "pysamstats/opt.pyx":1160
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 * 
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1161
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":1164
 * 
 *         # do the counting
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2
 */
  __pyx_t_2 = ((!(__pyx_v_read->is_del != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1165
 *         # do the counting
 *         if not read.is_del:
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]             # <<<<<<<<<<<<<<
 *             baseq_squared = baseq**2
 * 
 */
    __pyx_v_baseq = (pysam_bam_get_qual(__pyx_v_read->b)[__pyx_v_read->qpos]);

    /* "pysamstats/opt.pyx":1166
 *         if not read.is_del:
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2             # <<<<<<<<<<<<<<
 * 
 *         self.helper.update(baseq_squared, is_proper_pair)
 */
    __pyx_v_baseq_squared = __Pyx_pow_int64_t(__pyx_v_baseq, 2);

    /* "pysamstats/opt.pyx":1164
 * 
 *         # do the counting
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2
 */
  }

  /* "pysamstats/opt.pyx":1168
 *             baseq_squared = baseq**2
 * 
 *         self.helper.update(baseq_squared, is_proper_pair)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqPpHelper *)__pyx_v_self->helper->__pyx_vtab)->update(__pyx_v_self->helper, __pyx_v_baseq_squared, __pyx_v_is_proper_pair);

  /* "pysamstats/opt.pyx":1152
 *         self.helper.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":1170
 *         self.helper.update(baseq_squared, is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_5Baseq_rec(struct __pyx_obj_10pysamstats_3opt_Baseq *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1174
 *         # make record
 *         rec = {
 *             'reads_all': self.helper.all.n,             # <<<<<<<<<<<<<<
 *             'reads_pp': self.helper.pp.n,
 *             'rms_baseq': self.helper.all.rms(),
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->helper->all->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1175
 *         rec = {
 *             'reads_all': self.helper.all.n,
 *             'reads_pp': self.helper.pp.n,             # <<<<<<<<<<<<<<
 *             'rms_baseq': self.helper.all.rms(),
 *             'rms_baseq_pp': self.helper.pp.rms(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->helper->pp->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1176
 *             'reads_all': self.helper.all.n,
 *             'reads_pp': self.helper.pp.n,
 *             'rms_baseq': self.helper.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_pp': self.helper.pp.rms(),
 *         }
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1176, __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_ERR(0, 1176, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_baseq, __pyx_t_2) < 0) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1177
 *             'reads_pp': self.helper.pp.n,
 *             'rms_baseq': self.helper.all.rms(),
 *             'rms_baseq_pp': self.helper.pp.rms(),             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1177, __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_ERR(0, 1177, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_baseq_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1174, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1181
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1181, __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_ERR(0, 1181, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1183
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1170
 *         self.helper.update(baseq_squared, is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* 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("pysamstats.opt.Baseq.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1197
 *         BaseqHelper pp_rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = BaseqHelper()
 *         self.fwd = BaseqHelper()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_19BaseqStrandPpHelper___init__(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1198
 * 
 *     def __init__(self):
 *         self.all = BaseqHelper()             # <<<<<<<<<<<<<<
 *         self.fwd = BaseqHelper()
 *         self.rev = BaseqHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->all);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->all));
  __pyx_v_self->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1199
 *     def __init__(self):
 *         self.all = BaseqHelper()
 *         self.fwd = BaseqHelper()             # <<<<<<<<<<<<<<
 *         self.rev = BaseqHelper()
 *         self.pp = BaseqHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->fwd);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->fwd));
  __pyx_v_self->fwd = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1200
 *         self.all = BaseqHelper()
 *         self.fwd = BaseqHelper()
 *         self.rev = BaseqHelper()             # <<<<<<<<<<<<<<
 *         self.pp = BaseqHelper()
 *         self.pp_fwd = BaseqHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->rev);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->rev));
  __pyx_v_self->rev = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1201
 *         self.fwd = BaseqHelper()
 *         self.rev = BaseqHelper()
 *         self.pp = BaseqHelper()             # <<<<<<<<<<<<<<
 *         self.pp_fwd = BaseqHelper()
 *         self.pp_rev = BaseqHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1201, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp));
  __pyx_v_self->pp = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1202
 *         self.rev = BaseqHelper()
 *         self.pp = BaseqHelper()
 *         self.pp_fwd = BaseqHelper()             # <<<<<<<<<<<<<<
 *         self.pp_rev = BaseqHelper()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp_fwd);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp_fwd));
  __pyx_v_self->pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1203
 *         self.pp = BaseqHelper()
 *         self.pp_fwd = BaseqHelper()
 *         self.pp_rev = BaseqHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pp_rev);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pp_rev));
  __pyx_v_self->pp_rev = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1204
 *         self.pp_fwd = BaseqHelper()
 *         self.pp_rev = BaseqHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1204, __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_ERR(0, 1204, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1197
 *         BaseqHelper pp_rev
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = BaseqHelper()
 *         self.fwd = BaseqHelper()
 */

  /* 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("pysamstats.opt.BaseqStrandPpHelper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1206
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.fwd.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_19BaseqStrandPpHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_19BaseqStrandPpHelper_2reset[] = "BaseqStrandPpHelper.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_19BaseqStrandPpHelper_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_19BaseqStrandPpHelper_2reset(((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_19BaseqStrandPpHelper_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1207
 * 
 *     def reset(self):
 *         self.all.reset()             # <<<<<<<<<<<<<<
 *         self.fwd.reset()
 *         self.rev.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1207, __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_ERR(0, 1207, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1208
 *     def reset(self):
 *         self.all.reset()
 *         self.fwd.reset()             # <<<<<<<<<<<<<<
 *         self.rev.reset()
 *         self.pp.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->fwd), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1208, __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_ERR(0, 1208, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1209
 *         self.all.reset()
 *         self.fwd.reset()
 *         self.rev.reset()             # <<<<<<<<<<<<<<
 *         self.pp.reset()
 *         self.pp_fwd.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->rev), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1209, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1209, __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_ERR(0, 1209, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1210
 *         self.fwd.reset()
 *         self.rev.reset()
 *         self.pp.reset()             # <<<<<<<<<<<<<<
 *         self.pp_fwd.reset()
 *         self.pp_rev.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1210, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1210, __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_ERR(0, 1210, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1211
 *         self.rev.reset()
 *         self.pp.reset()
 *         self.pp_fwd.reset()             # <<<<<<<<<<<<<<
 *         self.pp_rev.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp_fwd), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1211, __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_ERR(0, 1211, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1212
 *         self.pp.reset()
 *         self.pp_fwd.reset()
 *         self.pp_rev.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair, bint is_reverse):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pp_rev), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1212, __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_ERR(0, 1212, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1206
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.fwd.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.BaseqStrandPpHelper.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1214
 *         self.pp_rev.reset()
 * 
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair, bint is_reverse):             # <<<<<<<<<<<<<<
 *         self.all.update(baseq_squared)
 *         if is_reverse:
 */

static void __pyx_f_10pysamstats_3opt_19BaseqStrandPpHelper_update(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *__pyx_v_self, int64_t __pyx_v_baseq_squared, int __pyx_v_is_proper_pair, int __pyx_v_is_reverse) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("update", 0);

  /* "pysamstats/opt.pyx":1215
 * 
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair, bint is_reverse):
 *         self.all.update(baseq_squared)             # <<<<<<<<<<<<<<
 *         if is_reverse:
 *             self.rev.update(baseq_squared)
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *)__pyx_v_self->all->__pyx_vtab)->update(__pyx_v_self->all, __pyx_v_baseq_squared);

  /* "pysamstats/opt.pyx":1216
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair, bint is_reverse):
 *         self.all.update(baseq_squared)
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.rev.update(baseq_squared)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_is_reverse != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":1217
 *         self.all.update(baseq_squared)
 *         if is_reverse:
 *             self.rev.update(baseq_squared)             # <<<<<<<<<<<<<<
 *         else:
 *             self.fwd.update(baseq_squared)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *)__pyx_v_self->rev->__pyx_vtab)->update(__pyx_v_self->rev, __pyx_v_baseq_squared);

    /* "pysamstats/opt.pyx":1216
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair, bint is_reverse):
 *         self.all.update(baseq_squared)
 *         if is_reverse:             # <<<<<<<<<<<<<<
 *             self.rev.update(baseq_squared)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":1219
 *             self.rev.update(baseq_squared)
 *         else:
 *             self.fwd.update(baseq_squared)             # <<<<<<<<<<<<<<
 *         if is_proper_pair:
 *             self.pp.update(baseq_squared)
 */
  /*else*/ {
    ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *)__pyx_v_self->fwd->__pyx_vtab)->update(__pyx_v_self->fwd, __pyx_v_baseq_squared);
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":1220
 *         else:
 *             self.fwd.update(baseq_squared)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.update(baseq_squared)
 *             if is_reverse:
 */
  __pyx_t_1 = (__pyx_v_is_proper_pair != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":1221
 *             self.fwd.update(baseq_squared)
 *         if is_proper_pair:
 *             self.pp.update(baseq_squared)             # <<<<<<<<<<<<<<
 *             if is_reverse:
 *                 self.pp_rev.update(baseq_squared)
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *)__pyx_v_self->pp->__pyx_vtab)->update(__pyx_v_self->pp, __pyx_v_baseq_squared);

    /* "pysamstats/opt.pyx":1222
 *         if is_proper_pair:
 *             self.pp.update(baseq_squared)
 *             if is_reverse:             # <<<<<<<<<<<<<<
 *                 self.pp_rev.update(baseq_squared)
 *             else:
 */
    __pyx_t_1 = (__pyx_v_is_reverse != 0);
    if (__pyx_t_1) {

      /* "pysamstats/opt.pyx":1223
 *             self.pp.update(baseq_squared)
 *             if is_reverse:
 *                 self.pp_rev.update(baseq_squared)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.pp_fwd.update(baseq_squared)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *)__pyx_v_self->pp_rev->__pyx_vtab)->update(__pyx_v_self->pp_rev, __pyx_v_baseq_squared);

      /* "pysamstats/opt.pyx":1222
 *         if is_proper_pair:
 *             self.pp.update(baseq_squared)
 *             if is_reverse:             # <<<<<<<<<<<<<<
 *                 self.pp_rev.update(baseq_squared)
 *             else:
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":1225
 *                 self.pp_rev.update(baseq_squared)
 *             else:
 *                 self.pp_fwd.update(baseq_squared)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqHelper *)__pyx_v_self->pp_fwd->__pyx_vtab)->update(__pyx_v_self->pp_fwd, __pyx_v_baseq_squared);
    }
    __pyx_L5:;

    /* "pysamstats/opt.pyx":1220
 *         else:
 *             self.fwd.update(baseq_squared)
 *         if is_proper_pair:             # <<<<<<<<<<<<<<
 *             self.pp.update(baseq_squared)
 *             if is_reverse:
 */
  }

  /* "pysamstats/opt.pyx":1214
 *         self.pp_rev.reset()
 * 
 *     cdef void update(self, int64_t baseq_squared, bint is_proper_pair, bint is_reverse):             # <<<<<<<<<<<<<<
 *         self.all.update(baseq_squared)
 *         if is_reverse:
 */

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

/* "pysamstats/opt.pyx":1234
 *         BaseqStrandPpHelper helper
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.helper = BaseqStrandPpHelper()
 *         self.reset()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_11BaseqStrand___init__(struct __pyx_obj_10pysamstats_3opt_BaseqStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1235
 * 
 *     def __init__(self):
 *         self.helper = BaseqStrandPpHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqStrandPpHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->helper);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->helper));
  __pyx_v_self->helper = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1236
 *     def __init__(self):
 *         self.helper = BaseqStrandPpHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1236, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1236, __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_ERR(0, 1236, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1234
 *         BaseqStrandPpHelper helper
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.helper = BaseqStrandPpHelper()
 *         self.reset()
 */

  /* 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("pysamstats.opt.BaseqStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1238
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.helper.reset()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_11BaseqStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_11BaseqStrand_2reset[] = "BaseqStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_11BaseqStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_11BaseqStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_BaseqStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_11BaseqStrand_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1239
 * 
 *     def reset(self):
 *         self.helper.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1239, __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_ERR(0, 1239, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1238
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.helper.reset()
 * 
 */

  /* 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_AddTraceback("pysamstats.opt.BaseqStrand.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1241
 *         self.helper.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_11BaseqStrand_recv(struct __pyx_obj_10pysamstats_3opt_BaseqStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int __pyx_v_is_reverse;
  int64_t __pyx_v_baseq;
  int64_t __pyx_v_baseq_squared;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1246
 *             bint is_proper_pair
 *             bint is_reverse
 *             int64_t baseq = -1             # <<<<<<<<<<<<<<
 *             int64_t baseq_squared = -1
 * 
 */
  __pyx_v_baseq = -1L;

  /* "pysamstats/opt.pyx":1247
 *             bint is_reverse
 *             int64_t baseq = -1
 *             int64_t baseq_squared = -1             # <<<<<<<<<<<<<<
 * 
 *         # convenience variables
 */
  __pyx_v_baseq_squared = -1L;

  /* "pysamstats/opt.pyx":1250
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1251
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 * 
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":1252
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":1255
 * 
 *         # do the counting
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2
 */
  __pyx_t_2 = ((!(__pyx_v_read->is_del != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1256
 *         # do the counting
 *         if not read.is_del:
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]             # <<<<<<<<<<<<<<
 *             baseq_squared = baseq**2
 * 
 */
    __pyx_v_baseq = (pysam_bam_get_qual(__pyx_v_read->b)[__pyx_v_read->qpos]);

    /* "pysamstats/opt.pyx":1257
 *         if not read.is_del:
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2             # <<<<<<<<<<<<<<
 * 
 *         self.helper.update(baseq_squared, is_proper_pair, is_reverse)
 */
    __pyx_v_baseq_squared = __Pyx_pow_int64_t(__pyx_v_baseq, 2);

    /* "pysamstats/opt.pyx":1255
 * 
 *         # do the counting
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2
 */
  }

  /* "pysamstats/opt.pyx":1259
 *             baseq_squared = baseq**2
 * 
 *         self.helper.update(baseq_squared, is_proper_pair, is_reverse)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_v_self->helper->__pyx_vtab)->update(__pyx_v_self->helper, __pyx_v_baseq_squared, __pyx_v_is_proper_pair, __pyx_v_is_reverse);

  /* "pysamstats/opt.pyx":1241
 *         self.helper.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

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

/* "pysamstats/opt.pyx":1261
 *         self.helper.update(baseq_squared, is_proper_pair, is_reverse)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_11BaseqStrand_rec(struct __pyx_obj_10pysamstats_3opt_BaseqStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1265
 *         # make record
 *         rec = {
 *             'reads_all': self.helper.all.n,             # <<<<<<<<<<<<<<
 *             'reads_fwd': self.helper.fwd.n,
 *             'reads_rev': self.helper.rev.n,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->helper->all->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1266
 *         rec = {
 *             'reads_all': self.helper.all.n,
 *             'reads_fwd': self.helper.fwd.n,             # <<<<<<<<<<<<<<
 *             'reads_rev': self.helper.rev.n,
 *             'reads_pp': self.helper.pp.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->helper->fwd->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1267
 *             'reads_all': self.helper.all.n,
 *             'reads_fwd': self.helper.fwd.n,
 *             'reads_rev': self.helper.rev.n,             # <<<<<<<<<<<<<<
 *             'reads_pp': self.helper.pp.n,
 *             'reads_pp_fwd': self.helper.pp_fwd.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->helper->rev->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1268
 *             'reads_fwd': self.helper.fwd.n,
 *             'reads_rev': self.helper.rev.n,
 *             'reads_pp': self.helper.pp.n,             # <<<<<<<<<<<<<<
 *             'reads_pp_fwd': self.helper.pp_fwd.n,
 *             'reads_pp_rev': self.helper.pp_rev.n,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->helper->pp->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1269
 *             'reads_rev': self.helper.rev.n,
 *             'reads_pp': self.helper.pp.n,
 *             'reads_pp_fwd': self.helper.pp_fwd.n,             # <<<<<<<<<<<<<<
 *             'reads_pp_rev': self.helper.pp_rev.n,
 *             'rms_baseq': self.helper.all.rms(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->helper->pp_fwd->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1270
 *             'reads_pp': self.helper.pp.n,
 *             'reads_pp_fwd': self.helper.pp_fwd.n,
 *             'reads_pp_rev': self.helper.pp_rev.n,             # <<<<<<<<<<<<<<
 *             'rms_baseq': self.helper.all.rms(),
 *             'rms_baseq_fwd': self.helper.fwd.rms(),
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->helper->pp_rev->n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1271
 *             'reads_pp_fwd': self.helper.pp_fwd.n,
 *             'reads_pp_rev': self.helper.pp_rev.n,
 *             'rms_baseq': self.helper.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_fwd': self.helper.fwd.rms(),
 *             'rms_baseq_rev': self.helper.rev.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1271, __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_ERR(0, 1271, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_baseq, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1272
 *             'reads_pp_rev': self.helper.pp_rev.n,
 *             'rms_baseq': self.helper.all.rms(),
 *             'rms_baseq_fwd': self.helper.fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_rev': self.helper.rev.rms(),
 *             'rms_baseq_pp': self.helper.pp.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper->fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1272, __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_ERR(0, 1272, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_baseq_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1273
 *             'rms_baseq': self.helper.all.rms(),
 *             'rms_baseq_fwd': self.helper.fwd.rms(),
 *             'rms_baseq_rev': self.helper.rev.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_pp': self.helper.pp.rms(),
 *             'rms_baseq_pp_fwd': self.helper.pp_fwd.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper->rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1273, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1273, __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_ERR(0, 1273, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_baseq_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1274
 *             'rms_baseq_fwd': self.helper.fwd.rms(),
 *             'rms_baseq_rev': self.helper.rev.rms(),
 *             'rms_baseq_pp': self.helper.pp.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_pp_fwd': self.helper.pp_fwd.rms(),
 *             'rms_baseq_pp_rev': self.helper.pp_rev.rms(),
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1274, __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_ERR(0, 1274, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_baseq_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1275
 *             'rms_baseq_rev': self.helper.rev.rms(),
 *             'rms_baseq_pp': self.helper.pp.rms(),
 *             'rms_baseq_pp_fwd': self.helper.pp_fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_pp_rev': self.helper.pp_rev.rms(),
 *         }
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper->pp_fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1275, __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_ERR(0, 1275, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_baseq_pp_fwd, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1276
 *             'rms_baseq_pp': self.helper.pp.rms(),
 *             'rms_baseq_pp_fwd': self.helper.pp_fwd.rms(),
 *             'rms_baseq_pp_rev': self.helper.pp_rev.rms(),             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->helper->pp_rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1276, __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_ERR(0, 1276, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_baseq_pp_rev, __pyx_t_2) < 0) __PYX_ERR(0, 1265, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1280
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1280, __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_ERR(0, 1280, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1282
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1261
 *         self.helper.update(baseq_squared, is_proper_pair, is_reverse)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* 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("pysamstats.opt.BaseqStrand.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1298
 *         BaseqPpHelper mismatches
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = BaseqPpHelper()
 *         self.matches = BaseqPpHelper()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_8BaseqExt___init__(struct __pyx_obj_10pysamstats_3opt_BaseqExt *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1299
 * 
 *     def __init__(self):
 *         self.all = BaseqPpHelper()             # <<<<<<<<<<<<<<
 *         self.matches = BaseqPpHelper()
 *         self.mismatches = BaseqPpHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqPpHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->all);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->all));
  __pyx_v_self->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1300
 *     def __init__(self):
 *         self.all = BaseqPpHelper()
 *         self.matches = BaseqPpHelper()             # <<<<<<<<<<<<<<
 *         self.mismatches = BaseqPpHelper()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqPpHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->matches);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->matches));
  __pyx_v_self->matches = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1301
 *         self.all = BaseqPpHelper()
 *         self.matches = BaseqPpHelper()
 *         self.mismatches = BaseqPpHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqPpHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mismatches);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mismatches));
  __pyx_v_self->mismatches = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1302
 *         self.matches = BaseqPpHelper()
 *         self.mismatches = BaseqPpHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1302, __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_ERR(0, 1302, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1298
 *         BaseqPpHelper mismatches
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = BaseqPpHelper()
 *         self.matches = BaseqPpHelper()
 */

  /* 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("pysamstats.opt.BaseqExt.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1304
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.matches.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_8BaseqExt_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_8BaseqExt_2reset[] = "BaseqExt.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_8BaseqExt_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_8BaseqExt_2reset(((struct __pyx_obj_10pysamstats_3opt_BaseqExt *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_8BaseqExt_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqExt *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1305
 * 
 *     def reset(self):
 *         self.all.reset()             # <<<<<<<<<<<<<<
 *         self.matches.reset()
 *         self.mismatches.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1305, __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_ERR(0, 1305, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1306
 *     def reset(self):
 *         self.all.reset()
 *         self.matches.reset()             # <<<<<<<<<<<<<<
 *         self.mismatches.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1306, __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_ERR(0, 1306, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1307
 *         self.all.reset()
 *         self.matches.reset()
 *         self.mismatches.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1307, __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_ERR(0, 1307, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1304
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.matches.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.BaseqExt.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1309
 *         self.mismatches.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_8BaseqExt_recv(struct __pyx_obj_10pysamstats_3opt_BaseqExt *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  CYTHON_UNUSED int __pyx_v_is_reverse;
  int64_t __pyx_v_baseq;
  int64_t __pyx_v_baseq_squared;
  PyObject *__pyx_v_alnbase = 0;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1314
 *             bint is_proper_pair
 *             bint is_reverse
 *             int64_t baseq = -1             # <<<<<<<<<<<<<<
 *             int64_t baseq_squared = -1
 *             bytes alnbase
 */
  __pyx_v_baseq = -1L;

  /* "pysamstats/opt.pyx":1315
 *             bint is_reverse
 *             int64_t baseq = -1
 *             int64_t baseq_squared = -1             # <<<<<<<<<<<<<<
 *             bytes alnbase
 * 
 */
  __pyx_v_baseq_squared = -1L;

  /* "pysamstats/opt.pyx":1319
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1320
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 * 
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":1321
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":1324
 * 
 *         # do the counting
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2
 */
  __pyx_t_2 = ((!(__pyx_v_read->is_del != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1325
 *         # do the counting
 *         if not read.is_del:
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]             # <<<<<<<<<<<<<<
 *             baseq_squared = baseq**2
 * 
 */
    __pyx_v_baseq = (pysam_bam_get_qual(__pyx_v_read->b)[__pyx_v_read->qpos]);

    /* "pysamstats/opt.pyx":1326
 *         if not read.is_del:
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2             # <<<<<<<<<<<<<<
 * 
 *         self.all.update(baseq_squared, is_proper_pair)
 */
    __pyx_v_baseq_squared = __Pyx_pow_int64_t(__pyx_v_baseq, 2);

    /* "pysamstats/opt.pyx":1324
 * 
 *         # do the counting
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2
 */
  }

  /* "pysamstats/opt.pyx":1328
 *             baseq_squared = baseq**2
 * 
 *         self.all.update(baseq_squared, is_proper_pair)             # <<<<<<<<<<<<<<
 *         if not read.is_del:
 *             alnbase = get_seq_base(read.b, read.qpos)
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqPpHelper *)__pyx_v_self->all->__pyx_vtab)->update(__pyx_v_self->all, __pyx_v_baseq_squared, __pyx_v_is_proper_pair);

  /* "pysamstats/opt.pyx":1329
 * 
 *         self.all.update(baseq_squared, is_proper_pair)
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:
 */
  __pyx_t_2 = ((!(__pyx_v_read->is_del != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1330
 *         self.all.update(baseq_squared, is_proper_pair)
 *         if not read.is_del:
 *             alnbase = get_seq_base(read.b, read.qpos)             # <<<<<<<<<<<<<<
 *             if alnbase == refbase:
 *                 self.matches.update(baseq_squared, is_proper_pair)
 */
    __pyx_t_3 = __pyx_f_10pysamstats_3opt_get_seq_base(__pyx_v_read->b, __pyx_v_read->qpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1330, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1330, __pyx_L1_error)
    __pyx_v_alnbase = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysamstats/opt.pyx":1331
 *         if not read.is_del:
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:             # <<<<<<<<<<<<<<
 *                 self.matches.update(baseq_squared, is_proper_pair)
 *             else:
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_v_refbase, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1331, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":1332
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:
 *                 self.matches.update(baseq_squared, is_proper_pair)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.mismatches.update(baseq_squared, is_proper_pair)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqPpHelper *)__pyx_v_self->matches->__pyx_vtab)->update(__pyx_v_self->matches, __pyx_v_baseq_squared, __pyx_v_is_proper_pair);

      /* "pysamstats/opt.pyx":1331
 *         if not read.is_del:
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:             # <<<<<<<<<<<<<<
 *                 self.matches.update(baseq_squared, is_proper_pair)
 *             else:
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":1334
 *                 self.matches.update(baseq_squared, is_proper_pair)
 *             else:
 *                 self.mismatches.update(baseq_squared, is_proper_pair)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqPpHelper *)__pyx_v_self->mismatches->__pyx_vtab)->update(__pyx_v_self->mismatches, __pyx_v_baseq_squared, __pyx_v_is_proper_pair);
    }
    __pyx_L5:;

    /* "pysamstats/opt.pyx":1329
 * 
 *         self.all.update(baseq_squared, is_proper_pair)
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:
 */
  }

  /* "pysamstats/opt.pyx":1309
 *         self.mismatches.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("pysamstats.opt.BaseqExt.recv", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_alnbase);
  __Pyx_RefNannyFinishContext();
}

/* "pysamstats/opt.pyx":1336
 *                 self.mismatches.update(baseq_squared, is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_8BaseqExt_rec(struct __pyx_obj_10pysamstats_3opt_BaseqExt *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_ref = NULL;
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1339
 * 
 *         # make record
 *         if PY2:             # <<<<<<<<<<<<<<
 *             ref = refbase
 *         else:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1339, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1340
 *         # make record
 *         if PY2:
 *             ref = refbase             # <<<<<<<<<<<<<<
 *         else:
 *             ref = str(refbase, 'ascii')
 */
    __Pyx_INCREF(__pyx_v_refbase);
    __pyx_v_ref = __pyx_v_refbase;

    /* "pysamstats/opt.pyx":1339
 * 
 *         # make record
 *         if PY2:             # <<<<<<<<<<<<<<
 *             ref = refbase
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":1342
 *             ref = refbase
 *         else:
 *             ref = str(refbase, 'ascii')             # <<<<<<<<<<<<<<
 *         rec = {
 *             'ref': ref,
 */
  /*else*/ {
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_refbase);
    __Pyx_GIVEREF(__pyx_v_refbase);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_refbase);
    __Pyx_INCREF(__pyx_n_s_ascii);
    __Pyx_GIVEREF(__pyx_n_s_ascii);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ascii);
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_ref = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":1344
 *             ref = str(refbase, 'ascii')
 *         rec = {
 *             'ref': ref,             # <<<<<<<<<<<<<<
 *             'reads_all': self.all.all.n,
 *             'reads_pp': self.all.pp.n,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ref, __pyx_v_ref) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1345
 *         rec = {
 *             'ref': ref,
 *             'reads_all': self.all.all.n,             # <<<<<<<<<<<<<<
 *             'reads_pp': self.all.pp.n,
 *             'matches': self.matches.all.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->all->all->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_all, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1346
 *             'ref': ref,
 *             'reads_all': self.all.all.n,
 *             'reads_pp': self.all.pp.n,             # <<<<<<<<<<<<<<
 *             'matches': self.matches.all.n,
 *             'matches_pp': self.matches.pp.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->all->pp->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1347
 *             'reads_all': self.all.all.n,
 *             'reads_pp': self.all.pp.n,
 *             'matches': self.matches.all.n,             # <<<<<<<<<<<<<<
 *             'matches_pp': self.matches.pp.n,
 *             'mismatches': self.mismatches.all.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->all->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1348
 *             'reads_pp': self.all.pp.n,
 *             'matches': self.matches.all.n,
 *             'matches_pp': self.matches.pp.n,             # <<<<<<<<<<<<<<
 *             'mismatches': self.mismatches.all.n,
 *             'mismatches_pp': self.mismatches.pp.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->pp->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1349
 *             'matches': self.matches.all.n,
 *             'matches_pp': self.matches.pp.n,
 *             'mismatches': self.mismatches.all.n,             # <<<<<<<<<<<<<<
 *             'mismatches_pp': self.mismatches.pp.n,
 *             'rms_baseq': self.all.all.rms(),
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->all->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1350
 *             'matches_pp': self.matches.pp.n,
 *             'mismatches': self.mismatches.all.n,
 *             'mismatches_pp': self.mismatches.pp.n,             # <<<<<<<<<<<<<<
 *             'rms_baseq': self.all.all.rms(),
 *             'rms_baseq_pp': self.all.pp.rms(),
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->pp->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1351
 *             'mismatches': self.mismatches.all.n,
 *             'mismatches_pp': self.mismatches.pp.n,
 *             'rms_baseq': self.all.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_pp': self.all.pp.rms(),
 *             'rms_baseq_matches': self.matches.all.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1351, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1351, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1352
 *             'mismatches_pp': self.mismatches.pp.n,
 *             'rms_baseq': self.all.all.rms(),
 *             'rms_baseq_pp': self.all.pp.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_matches': self.matches.all.rms(),
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1352, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1352, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1353
 *             'rms_baseq': self.all.all.rms(),
 *             'rms_baseq_pp': self.all.pp.rms(),
 *             'rms_baseq_matches': self.matches.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_matches, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1354
 *             'rms_baseq_pp': self.all.pp.rms(),
 *             'rms_baseq_matches': self.matches.all.rms(),
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),
 *             'rms_baseq_mismatches_pp': self.mismatches.pp.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1354, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1354, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_matches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1355
 *             'rms_baseq_matches': self.matches.all.rms(),
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_mismatches_pp': self.mismatches.pp.rms(),
 *         }
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1355, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1355, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_mismatches, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1356
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),
 *             'rms_baseq_mismatches_pp': self.mismatches.pp.rms(),             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1356, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1356, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1356, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_mismatches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1344, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1360
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1360, __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;

  /* "pysamstats/opt.pyx":1362
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1336
 *                 self.mismatches.update(baseq_squared, is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* 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("pysamstats.opt.BaseqExt.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref);
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1373
 *         BaseqStrandPpHelper mismatches
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = BaseqStrandPpHelper()
 *         self.matches = BaseqStrandPpHelper()
 */

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

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

static int __pyx_pf_10pysamstats_3opt_14BaseqExtStrand___init__(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1374
 * 
 *     def __init__(self):
 *         self.all = BaseqStrandPpHelper()             # <<<<<<<<<<<<<<
 *         self.matches = BaseqStrandPpHelper()
 *         self.mismatches = BaseqStrandPpHelper()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqStrandPpHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1374, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->all);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->all));
  __pyx_v_self->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1375
 *     def __init__(self):
 *         self.all = BaseqStrandPpHelper()
 *         self.matches = BaseqStrandPpHelper()             # <<<<<<<<<<<<<<
 *         self.mismatches = BaseqStrandPpHelper()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqStrandPpHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->matches);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->matches));
  __pyx_v_self->matches = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1376
 *         self.all = BaseqStrandPpHelper()
 *         self.matches = BaseqStrandPpHelper()
 *         self.mismatches = BaseqStrandPpHelper()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_BaseqStrandPpHelper), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->mismatches);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->mismatches));
  __pyx_v_self->mismatches = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1377
 *         self.matches = BaseqStrandPpHelper()
 *         self.mismatches = BaseqStrandPpHelper()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1377, __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_ERR(0, 1377, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1373
 *         BaseqStrandPpHelper mismatches
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.all = BaseqStrandPpHelper()
 *         self.matches = BaseqStrandPpHelper()
 */

  /* 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("pysamstats.opt.BaseqExtStrand.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1379
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.matches.reset()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_14BaseqExtStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_14BaseqExtStrand_2reset[] = "BaseqExtStrand.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_14BaseqExtStrand_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_14BaseqExtStrand_2reset(((struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_14BaseqExtStrand_2reset(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1380
 * 
 *     def reset(self):
 *         self.all.reset()             # <<<<<<<<<<<<<<
 *         self.matches.reset()
 *         self.mismatches.reset()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1380, __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_ERR(0, 1380, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1381
 *     def reset(self):
 *         self.all.reset()
 *         self.matches.reset()             # <<<<<<<<<<<<<<
 *         self.mismatches.reset()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1381, __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_ERR(0, 1381, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1382
 *         self.all.reset()
 *         self.matches.reset()
 *         self.mismatches.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1382, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1382, __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_ERR(0, 1382, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1379
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.all.reset()
 *         self.matches.reset()
 */

  /* 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_AddTraceback("pysamstats.opt.BaseqExtStrand.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1384
 *         self.mismatches.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

static void __pyx_f_10pysamstats_3opt_14BaseqExtStrand_recv(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, PyObject *__pyx_v_refbase) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_proper_pair;
  int __pyx_v_is_reverse;
  int64_t __pyx_v_baseq;
  int64_t __pyx_v_baseq_squared;
  PyObject *__pyx_v_alnbase = 0;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1389
 *             bint is_proper_pair
 *             bint is_reverse
 *             int64_t baseq = -1             # <<<<<<<<<<<<<<
 *             int64_t baseq_squared = -1
 *             bytes alnbase
 */
  __pyx_v_baseq = -1L;

  /* "pysamstats/opt.pyx":1390
 *             bint is_reverse
 *             int64_t baseq = -1
 *             int64_t baseq_squared = -1             # <<<<<<<<<<<<<<
 *             bytes alnbase
 * 
 */
  __pyx_v_baseq_squared = -1L;

  /* "pysamstats/opt.pyx":1394
 * 
 *         # convenience variables
 *         flag = read.b.core.flag             # <<<<<<<<<<<<<<
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 */
  __pyx_t_1 = __pyx_v_read->b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1395
 *         # convenience variables
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *         is_reverse = <bint>(flag & BAM_FREVERSE)
 * 
 */
  __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

  /* "pysamstats/opt.pyx":1396
 *         flag = read.b.core.flag
 *         is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *         is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

  /* "pysamstats/opt.pyx":1399
 * 
 *         # do the counting
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2
 */
  __pyx_t_2 = ((!(__pyx_v_read->is_del != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1400
 *         # do the counting
 *         if not read.is_del:
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]             # <<<<<<<<<<<<<<
 *             baseq_squared = baseq**2
 * 
 */
    __pyx_v_baseq = (pysam_bam_get_qual(__pyx_v_read->b)[__pyx_v_read->qpos]);

    /* "pysamstats/opt.pyx":1401
 *         if not read.is_del:
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2             # <<<<<<<<<<<<<<
 * 
 *         self.all.update(baseq_squared, is_proper_pair, is_reverse)
 */
    __pyx_v_baseq_squared = __Pyx_pow_int64_t(__pyx_v_baseq, 2);

    /* "pysamstats/opt.pyx":1399
 * 
 *         # do the counting
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             baseq = pysam_bam_get_qual(read.b)[read.qpos]
 *             baseq_squared = baseq**2
 */
  }

  /* "pysamstats/opt.pyx":1403
 *             baseq_squared = baseq**2
 * 
 *         self.all.update(baseq_squared, is_proper_pair, is_reverse)             # <<<<<<<<<<<<<<
 *         if not read.is_del:
 *             alnbase = get_seq_base(read.b, read.qpos)
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_v_self->all->__pyx_vtab)->update(__pyx_v_self->all, __pyx_v_baseq_squared, __pyx_v_is_proper_pair, __pyx_v_is_reverse);

  /* "pysamstats/opt.pyx":1404
 * 
 *         self.all.update(baseq_squared, is_proper_pair, is_reverse)
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:
 */
  __pyx_t_2 = ((!(__pyx_v_read->is_del != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1405
 *         self.all.update(baseq_squared, is_proper_pair, is_reverse)
 *         if not read.is_del:
 *             alnbase = get_seq_base(read.b, read.qpos)             # <<<<<<<<<<<<<<
 *             if alnbase == refbase:
 *                 self.matches.update(baseq_squared, is_proper_pair, is_reverse)
 */
    __pyx_t_3 = __pyx_f_10pysamstats_3opt_get_seq_base(__pyx_v_read->b, __pyx_v_read->qpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1405, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1405, __pyx_L1_error)
    __pyx_v_alnbase = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysamstats/opt.pyx":1406
 *         if not read.is_del:
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:             # <<<<<<<<<<<<<<
 *                 self.matches.update(baseq_squared, is_proper_pair, is_reverse)
 *             else:
 */
    __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_v_alnbase, __pyx_v_refbase, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1406, __pyx_L1_error)
    __pyx_t_4 = (__pyx_t_2 != 0);
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":1407
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:
 *                 self.matches.update(baseq_squared, is_proper_pair, is_reverse)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.mismatches.update(baseq_squared, is_proper_pair, is_reverse)
 */
      ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_v_self->matches->__pyx_vtab)->update(__pyx_v_self->matches, __pyx_v_baseq_squared, __pyx_v_is_proper_pair, __pyx_v_is_reverse);

      /* "pysamstats/opt.pyx":1406
 *         if not read.is_del:
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:             # <<<<<<<<<<<<<<
 *                 self.matches.update(baseq_squared, is_proper_pair, is_reverse)
 *             else:
 */
      goto __pyx_L5;
    }

    /* "pysamstats/opt.pyx":1409
 *                 self.matches.update(baseq_squared, is_proper_pair, is_reverse)
 *             else:
 *                 self.mismatches.update(baseq_squared, is_proper_pair, is_reverse)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
    /*else*/ {
      ((struct __pyx_vtabstruct_10pysamstats_3opt_BaseqStrandPpHelper *)__pyx_v_self->mismatches->__pyx_vtab)->update(__pyx_v_self->mismatches, __pyx_v_baseq_squared, __pyx_v_is_proper_pair, __pyx_v_is_reverse);
    }
    __pyx_L5:;

    /* "pysamstats/opt.pyx":1404
 * 
 *         self.all.update(baseq_squared, is_proper_pair, is_reverse)
 *         if not read.is_del:             # <<<<<<<<<<<<<<
 *             alnbase = get_seq_base(read.b, read.qpos)
 *             if alnbase == refbase:
 */
  }

  /* "pysamstats/opt.pyx":1384
 *         self.mismatches.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             uint32_t flag
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("pysamstats.opt.BaseqExtStrand.recv", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_alnbase);
  __Pyx_RefNannyFinishContext();
}

/* "pysamstats/opt.pyx":1411
 *                 self.mismatches.update(baseq_squared, is_proper_pair, is_reverse)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

static PyObject *__pyx_f_10pysamstats_3opt_14BaseqExtStrand_rec(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_pos, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_ref = NULL;
  PyObject *__pyx_v_rec = 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;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1414
 * 
 *         # make record
 *         if PY2:             # <<<<<<<<<<<<<<
 *             ref = refbase
 *         else:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1415
 *         # make record
 *         if PY2:
 *             ref = refbase             # <<<<<<<<<<<<<<
 *         else:
 *             ref = str(refbase, 'ascii')
 */
    __Pyx_INCREF(__pyx_v_refbase);
    __pyx_v_ref = __pyx_v_refbase;

    /* "pysamstats/opt.pyx":1414
 * 
 *         # make record
 *         if PY2:             # <<<<<<<<<<<<<<
 *             ref = refbase
 *         else:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":1417
 *             ref = refbase
 *         else:
 *             ref = str(refbase, 'ascii')             # <<<<<<<<<<<<<<
 *         rec = {
 *             'ref': ref,
 */
  /*else*/ {
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_refbase);
    __Pyx_GIVEREF(__pyx_v_refbase);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_refbase);
    __Pyx_INCREF(__pyx_n_s_ascii);
    __Pyx_GIVEREF(__pyx_n_s_ascii);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ascii);
    __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_ref = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":1419
 *             ref = str(refbase, 'ascii')
 *         rec = {
 *             'ref': ref,             # <<<<<<<<<<<<<<
 *             'reads_all': self.all.all.n,
 *             'reads_fwd': self.all.fwd.n,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ref, __pyx_v_ref) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1420
 *         rec = {
 *             'ref': ref,
 *             'reads_all': self.all.all.n,             # <<<<<<<<<<<<<<
 *             'reads_fwd': self.all.fwd.n,
 *             'reads_rev': self.all.rev.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->all->all->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_all, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1421
 *             'ref': ref,
 *             'reads_all': self.all.all.n,
 *             'reads_fwd': self.all.fwd.n,             # <<<<<<<<<<<<<<
 *             'reads_rev': self.all.rev.n,
 *             'reads_pp': self.all.pp.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->all->fwd->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1422
 *             'reads_all': self.all.all.n,
 *             'reads_fwd': self.all.fwd.n,
 *             'reads_rev': self.all.rev.n,             # <<<<<<<<<<<<<<
 *             'reads_pp': self.all.pp.n,
 *             'reads_pp_fwd': self.all.pp_fwd.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->all->rev->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1423
 *             'reads_fwd': self.all.fwd.n,
 *             'reads_rev': self.all.rev.n,
 *             'reads_pp': self.all.pp.n,             # <<<<<<<<<<<<<<
 *             'reads_pp_fwd': self.all.pp_fwd.n,
 *             'reads_pp_rev': self.all.pp_rev.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->all->pp->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1424
 *             'reads_rev': self.all.rev.n,
 *             'reads_pp': self.all.pp.n,
 *             'reads_pp_fwd': self.all.pp_fwd.n,             # <<<<<<<<<<<<<<
 *             'reads_pp_rev': self.all.pp_rev.n,
 *             'matches': self.matches.all.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->all->pp_fwd->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1424, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1425
 *             'reads_pp': self.all.pp.n,
 *             'reads_pp_fwd': self.all.pp_fwd.n,
 *             'reads_pp_rev': self.all.pp_rev.n,             # <<<<<<<<<<<<<<
 *             'matches': self.matches.all.n,
 *             'matches_fwd': self.matches.fwd.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->all->pp_rev->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_reads_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1426
 *             'reads_pp_fwd': self.all.pp_fwd.n,
 *             'reads_pp_rev': self.all.pp_rev.n,
 *             'matches': self.matches.all.n,             # <<<<<<<<<<<<<<
 *             'matches_fwd': self.matches.fwd.n,
 *             'matches_rev': self.matches.rev.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->all->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1427
 *             'reads_pp_rev': self.all.pp_rev.n,
 *             'matches': self.matches.all.n,
 *             'matches_fwd': self.matches.fwd.n,             # <<<<<<<<<<<<<<
 *             'matches_rev': self.matches.rev.n,
 *             'matches_pp': self.matches.pp.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->fwd->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1428
 *             'matches': self.matches.all.n,
 *             'matches_fwd': self.matches.fwd.n,
 *             'matches_rev': self.matches.rev.n,             # <<<<<<<<<<<<<<
 *             'matches_pp': self.matches.pp.n,
 *             'matches_pp_fwd': self.matches.pp_fwd.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->rev->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1429
 *             'matches_fwd': self.matches.fwd.n,
 *             'matches_rev': self.matches.rev.n,
 *             'matches_pp': self.matches.pp.n,             # <<<<<<<<<<<<<<
 *             'matches_pp_fwd': self.matches.pp_fwd.n,
 *             'matches_pp_rev': self.matches.pp_rev.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->pp->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1430
 *             'matches_rev': self.matches.rev.n,
 *             'matches_pp': self.matches.pp.n,
 *             'matches_pp_fwd': self.matches.pp_fwd.n,             # <<<<<<<<<<<<<<
 *             'matches_pp_rev': self.matches.pp_rev.n,
 *             'mismatches': self.mismatches.all.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->pp_fwd->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1431
 *             'matches_pp': self.matches.pp.n,
 *             'matches_pp_fwd': self.matches.pp_fwd.n,
 *             'matches_pp_rev': self.matches.pp_rev.n,             # <<<<<<<<<<<<<<
 *             'mismatches': self.mismatches.all.n,
 *             'mismatches_fwd': self.mismatches.fwd.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->matches->pp_rev->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_matches_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1432
 *             'matches_pp_fwd': self.matches.pp_fwd.n,
 *             'matches_pp_rev': self.matches.pp_rev.n,
 *             'mismatches': self.mismatches.all.n,             # <<<<<<<<<<<<<<
 *             'mismatches_fwd': self.mismatches.fwd.n,
 *             'mismatches_rev': self.mismatches.rev.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->all->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1433
 *             'matches_pp_rev': self.matches.pp_rev.n,
 *             'mismatches': self.mismatches.all.n,
 *             'mismatches_fwd': self.mismatches.fwd.n,             # <<<<<<<<<<<<<<
 *             'mismatches_rev': self.mismatches.rev.n,
 *             'mismatches_pp': self.mismatches.pp.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->fwd->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1433, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1434
 *             'mismatches': self.mismatches.all.n,
 *             'mismatches_fwd': self.mismatches.fwd.n,
 *             'mismatches_rev': self.mismatches.rev.n,             # <<<<<<<<<<<<<<
 *             'mismatches_pp': self.mismatches.pp.n,
 *             'mismatches_pp_fwd': self.mismatches.pp_fwd.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->rev->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1434, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1435
 *             'mismatches_fwd': self.mismatches.fwd.n,
 *             'mismatches_rev': self.mismatches.rev.n,
 *             'mismatches_pp': self.mismatches.pp.n,             # <<<<<<<<<<<<<<
 *             'mismatches_pp_fwd': self.mismatches.pp_fwd.n,
 *             'mismatches_pp_rev': self.mismatches.pp_rev.n,
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->pp->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1435, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1436
 *             'mismatches_rev': self.mismatches.rev.n,
 *             'mismatches_pp': self.mismatches.pp.n,
 *             'mismatches_pp_fwd': self.mismatches.pp_fwd.n,             # <<<<<<<<<<<<<<
 *             'mismatches_pp_rev': self.mismatches.pp_rev.n,
 *             'rms_baseq': self.all.all.rms(),
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->pp_fwd->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1436, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1437
 *             'mismatches_pp': self.mismatches.pp.n,
 *             'mismatches_pp_fwd': self.mismatches.pp_fwd.n,
 *             'mismatches_pp_rev': self.mismatches.pp_rev.n,             # <<<<<<<<<<<<<<
 *             'rms_baseq': self.all.all.rms(),
 *             'rms_baseq_fwd': self.all.fwd.rms(),
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->mismatches->pp_rev->n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1437, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mismatches_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1438
 *             'mismatches_pp_fwd': self.mismatches.pp_fwd.n,
 *             'mismatches_pp_rev': self.mismatches.pp_rev.n,
 *             'rms_baseq': self.all.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_fwd': self.all.fwd.rms(),
 *             'rms_baseq_rev': self.all.rev.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1438, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1438, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1439
 *             'mismatches_pp_rev': self.mismatches.pp_rev.n,
 *             'rms_baseq': self.all.all.rms(),
 *             'rms_baseq_fwd': self.all.fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_rev': self.all.rev.rms(),
 *             'rms_baseq_pp': self.all.pp.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all->fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1439, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1439, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1440
 *             'rms_baseq': self.all.all.rms(),
 *             'rms_baseq_fwd': self.all.fwd.rms(),
 *             'rms_baseq_rev': self.all.rev.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_pp': self.all.pp.rms(),
 *             'rms_baseq_pp_fwd': self.all.pp_fwd.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all->rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1440, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1440, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1440, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1441
 *             'rms_baseq_fwd': self.all.fwd.rms(),
 *             'rms_baseq_rev': self.all.rev.rms(),
 *             'rms_baseq_pp': self.all.pp.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_pp_fwd': self.all.pp_fwd.rms(),
 *             'rms_baseq_pp_rev': self.all.pp_rev.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1441, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1441, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1442
 *             'rms_baseq_rev': self.all.rev.rms(),
 *             'rms_baseq_pp': self.all.pp.rms(),
 *             'rms_baseq_pp_fwd': self.all.pp_fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_pp_rev': self.all.pp_rev.rms(),
 *             'rms_baseq_matches': self.matches.all.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all->pp_fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1442, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1442, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1443
 *             'rms_baseq_pp': self.all.pp.rms(),
 *             'rms_baseq_pp_fwd': self.all.pp_fwd.rms(),
 *             'rms_baseq_pp_rev': self.all.pp_rev.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_matches': self.matches.all.rms(),
 *             'rms_baseq_matches_fwd': self.matches.fwd.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->all->pp_rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1443, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1443, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1444
 *             'rms_baseq_pp_fwd': self.all.pp_fwd.rms(),
 *             'rms_baseq_pp_rev': self.all.pp_rev.rms(),
 *             'rms_baseq_matches': self.matches.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_matches_fwd': self.matches.fwd.rms(),
 *             'rms_baseq_matches_rev': self.matches.rev.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1444, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1444, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_matches, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1445
 *             'rms_baseq_pp_rev': self.all.pp_rev.rms(),
 *             'rms_baseq_matches': self.matches.all.rms(),
 *             'rms_baseq_matches_fwd': self.matches.fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_matches_rev': self.matches.rev.rms(),
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches->fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1445, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1445, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1445, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_matches_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1446
 *             'rms_baseq_matches': self.matches.all.rms(),
 *             'rms_baseq_matches_fwd': self.matches.fwd.rms(),
 *             'rms_baseq_matches_rev': self.matches.rev.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),
 *             'rms_baseq_matches_pp_fwd': self.matches.pp_fwd.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches->rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1446, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1446, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_matches_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1447
 *             'rms_baseq_matches_fwd': self.matches.fwd.rms(),
 *             'rms_baseq_matches_rev': self.matches.rev.rms(),
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_matches_pp_fwd': self.matches.pp_fwd.rms(),
 *             'rms_baseq_matches_pp_rev': self.matches.pp_rev.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1447, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1447, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_matches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1448
 *             'rms_baseq_matches_rev': self.matches.rev.rms(),
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),
 *             'rms_baseq_matches_pp_fwd': self.matches.pp_fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_matches_pp_rev': self.matches.pp_rev.rms(),
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches->pp_fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1448, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1448, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1448, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_matches_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1449
 *             'rms_baseq_matches_pp': self.matches.pp.rms(),
 *             'rms_baseq_matches_pp_fwd': self.matches.pp_fwd.rms(),
 *             'rms_baseq_matches_pp_rev': self.matches.pp_rev.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),
 *             'rms_baseq_mismatches_fwd': self.mismatches.fwd.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->matches->pp_rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1449, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1449, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_matches_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1450
 *             'rms_baseq_matches_pp_fwd': self.matches.pp_fwd.rms(),
 *             'rms_baseq_matches_pp_rev': self.matches.pp_rev.rms(),
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_mismatches_fwd': self.mismatches.fwd.rms(),
 *             'rms_baseq_mismatches_rev': self.mismatches.rev.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches->all), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1450, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1450, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_mismatches, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1451
 *             'rms_baseq_matches_pp_rev': self.matches.pp_rev.rms(),
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),
 *             'rms_baseq_mismatches_fwd': self.mismatches.fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_mismatches_rev': self.mismatches.rev.rms(),
 *             'rms_baseq_mismatches_pp': self.mismatches.pp.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches->fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1451, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1451, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_mismatches_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1452
 *             'rms_baseq_mismatches': self.mismatches.all.rms(),
 *             'rms_baseq_mismatches_fwd': self.mismatches.fwd.rms(),
 *             'rms_baseq_mismatches_rev': self.mismatches.rev.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_mismatches_pp': self.mismatches.pp.rms(),
 *             'rms_baseq_mismatches_pp_fwd': self.mismatches.pp_fwd.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches->rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1452, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1452, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1452, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_mismatches_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1453
 *             'rms_baseq_mismatches_fwd': self.mismatches.fwd.rms(),
 *             'rms_baseq_mismatches_rev': self.mismatches.rev.rms(),
 *             'rms_baseq_mismatches_pp': self.mismatches.pp.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_mismatches_pp_fwd': self.mismatches.pp_fwd.rms(),
 *             'rms_baseq_mismatches_pp_rev': self.mismatches.pp_rev.rms(),
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches->pp), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1453, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1453, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1453, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_mismatches_pp, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1454
 *             'rms_baseq_mismatches_rev': self.mismatches.rev.rms(),
 *             'rms_baseq_mismatches_pp': self.mismatches.pp.rms(),
 *             'rms_baseq_mismatches_pp_fwd': self.mismatches.pp_fwd.rms(),             # <<<<<<<<<<<<<<
 *             'rms_baseq_mismatches_pp_rev': self.mismatches.pp_rev.rms(),
 *         }
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches->pp_fwd), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1454, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1454, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1454, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_mismatches_pp_fwd, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1455
 *             'rms_baseq_mismatches_pp': self.mismatches.pp.rms(),
 *             'rms_baseq_mismatches_pp_fwd': self.mismatches.pp_fwd.rms(),
 *             'rms_baseq_mismatches_pp_rev': self.mismatches.pp_rev.rms(),             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->mismatches->pp_rev), __pyx_n_s_rms); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1455, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1455, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_rms_baseq_mismatches_pp_rev, __pyx_t_1) < 0) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1459
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1459, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1459, __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;

  /* "pysamstats/opt.pyx":1461
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1411
 *                 self.mismatches.update(baseq_squared, is_proper_pair, is_reverse)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */

  /* 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("pysamstats.opt.BaseqExtStrand.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref);
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1476
 *         int window_size, window_offset
 * 
 *     def __init__(self, window_size, window_offset):             # <<<<<<<<<<<<<<
 *         self.window_size = window_size
 *         if window_offset is None:
 */

/* Python wrapper */
static int __pyx_pw_10pysamstats_3opt_10CoverageGC_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_10pysamstats_3opt_10CoverageGC_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_window_size = 0;
  PyObject *__pyx_v_window_offset = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_window_size,&__pyx_n_s_window_offset,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_window_size)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window_offset)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 1476, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1476, __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_window_size = values[0];
    __pyx_v_window_offset = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1476, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.CoverageGC.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10pysamstats_3opt_10CoverageGC___init__(((struct __pyx_obj_10pysamstats_3opt_CoverageGC *)__pyx_v_self), __pyx_v_window_size, __pyx_v_window_offset);

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

static int __pyx_pf_10pysamstats_3opt_10CoverageGC___init__(struct __pyx_obj_10pysamstats_3opt_CoverageGC *__pyx_v_self, PyObject *__pyx_v_window_size, PyObject *__pyx_v_window_offset) {
  int __pyx_r;
  __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;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_INCREF(__pyx_v_window_offset);

  /* "pysamstats/opt.pyx":1477
 * 
 *     def __init__(self, window_size, window_offset):
 *         self.window_size = window_size             # <<<<<<<<<<<<<<
 *         if window_offset is None:
 *             window_offset = window_size // 2
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_window_size); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1477, __pyx_L1_error)
  __pyx_v_self->window_size = __pyx_t_1;

  /* "pysamstats/opt.pyx":1478
 *     def __init__(self, window_size, window_offset):
 *         self.window_size = window_size
 *         if window_offset is None:             # <<<<<<<<<<<<<<
 *             window_offset = window_size // 2
 *         self.window_offset = window_offset
 */
  __pyx_t_2 = (__pyx_v_window_offset == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":1479
 *         self.window_size = window_size
 *         if window_offset is None:
 *             window_offset = window_size // 2             # <<<<<<<<<<<<<<
 *         self.window_offset = window_offset
 *         self.reads = CountPp()
 */
    __pyx_t_4 = __Pyx_PyInt_FloorDivideObjC(__pyx_v_window_size, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_window_offset, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysamstats/opt.pyx":1478
 *     def __init__(self, window_size, window_offset):
 *         self.window_size = window_size
 *         if window_offset is None:             # <<<<<<<<<<<<<<
 *             window_offset = window_size // 2
 *         self.window_offset = window_offset
 */
  }

  /* "pysamstats/opt.pyx":1480
 *         if window_offset is None:
 *             window_offset = window_size // 2
 *         self.window_offset = window_offset             # <<<<<<<<<<<<<<
 *         self.reads = CountPp()
 *         self.reset()
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_window_offset); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1480, __pyx_L1_error)
  __pyx_v_self->window_offset = __pyx_t_1;

  /* "pysamstats/opt.pyx":1481
 *             window_offset = window_size // 2
 *         self.window_offset = window_offset
 *         self.reads = CountPp()             # <<<<<<<<<<<<<<
 *         self.reset()
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10pysamstats_3opt_CountPp), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->reads);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->reads));
  __pyx_v_self->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysamstats/opt.pyx":1482
 *         self.window_offset = window_offset
 *         self.reads = CountPp()
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *     def reset(self):
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1482, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1482, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1482, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pysamstats/opt.pyx":1476
 *         int window_size, window_offset
 * 
 *     def __init__(self, window_size, window_offset):             # <<<<<<<<<<<<<<
 *         self.window_size = window_size
 *         if window_offset is None:
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("pysamstats.opt.CoverageGC.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_window_offset);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1484
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10CoverageGC_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_10pysamstats_3opt_10CoverageGC_2reset[] = "CoverageGC.reset(self)";
static PyObject *__pyx_pw_10pysamstats_3opt_10CoverageGC_3reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset (wrapper)", 0);
  __pyx_r = __pyx_pf_10pysamstats_3opt_10CoverageGC_2reset(((struct __pyx_obj_10pysamstats_3opt_CoverageGC *)__pyx_v_self));

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

static PyObject *__pyx_pf_10pysamstats_3opt_10CoverageGC_2reset(struct __pyx_obj_10pysamstats_3opt_CoverageGC *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("reset", 0);

  /* "pysamstats/opt.pyx":1485
 * 
 *     def reset(self):
 *         self.reads.reset()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->reads), __pyx_n_s_reset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1485, __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_ERR(0, 1485, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1484
 *         self.reset()
 * 
 *     def reset(self):             # <<<<<<<<<<<<<<
 *         self.reads.reset()
 * 
 */

  /* 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_AddTraceback("pysamstats.opt.CoverageGC.reset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1487
 *         self.reads.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             bint is_proper_pair
 */

static void __pyx_f_10pysamstats_3opt_10CoverageGC_recv(struct __pyx_obj_10pysamstats_3opt_CoverageGC *__pyx_v_self, bam_pileup1_t *__pyx_v_read, CYTHON_UNUSED struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  int __pyx_v_is_proper_pair;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1492
 * 
 *         # convenience variables
 *         is_proper_pair = <bint>(read.b.core.flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 * 
 *         # do the counting
 */
  __pyx_v_is_proper_pair = ((__pyx_v_read->b->core.flag & 2) != 0);

  /* "pysamstats/opt.pyx":1495
 * 
 *         # do the counting
 *         self.reads.incr(is_proper_pair)             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):
 */
  ((struct __pyx_vtabstruct_10pysamstats_3opt_CountPp *)__pyx_v_self->reads->__pyx_vtab)->incr(__pyx_v_self->reads, __pyx_v_is_proper_pair);

  /* "pysamstats/opt.pyx":1487
 *         self.reads.reset()
 * 
 *     cdef void recv(self, bam_pileup1_t* read, PileupColumn col, bytes refbase):             # <<<<<<<<<<<<<<
 *         cdef:
 *             bint is_proper_pair
 */

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

/* "pysamstats/opt.pyx":1497
 *         self.reads.incr(is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # compute GC
 */

static PyObject *__pyx_f_10pysamstats_3opt_10CoverageGC_rec(struct __pyx_obj_10pysamstats_3opt_CoverageGC *__pyx_v_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_pos, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, CYTHON_UNUSED PyObject *__pyx_v_refbase) {
  PyObject *__pyx_v_ref_window_start = NULL;
  PyObject *__pyx_v_ref_window_end = NULL;
  PyObject *__pyx_v_ref_window = NULL;
  long __pyx_v_gc;
  PyObject *__pyx_v_rec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1500
 * 
 *         # compute GC
 *         ref_window_start = pos - self.window_offset             # <<<<<<<<<<<<<<
 *         ref_window_end = ref_window_start + self.window_size
 *         if ref_window_start < 0:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->window_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Subtract(__pyx_v_pos, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_ref_window_start = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1501
 *         # compute GC
 *         ref_window_start = pos - self.window_offset
 *         ref_window_end = ref_window_start + self.window_size             # <<<<<<<<<<<<<<
 *         if ref_window_start < 0:
 *             ref_window_start = 0
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->window_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Add(__pyx_v_ref_window_start, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ref_window_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1502
 *         ref_window_start = pos - self.window_offset
 *         ref_window_end = ref_window_start + self.window_size
 *         if ref_window_start < 0:             # <<<<<<<<<<<<<<
 *             ref_window_start = 0
 *         ref_window = fafile.fetch(chrom, ref_window_start, ref_window_end).lower()
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_ref_window_start, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1502, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1502, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":1503
 *         ref_window_end = ref_window_start + self.window_size
 *         if ref_window_start < 0:
 *             ref_window_start = 0             # <<<<<<<<<<<<<<
 *         ref_window = fafile.fetch(chrom, ref_window_start, ref_window_end).lower()
 *         if len(ref_window) == 0:
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF_SET(__pyx_v_ref_window_start, __pyx_int_0);

    /* "pysamstats/opt.pyx":1502
 *         ref_window_start = pos - self.window_offset
 *         ref_window_end = ref_window_start + self.window_size
 *         if ref_window_start < 0:             # <<<<<<<<<<<<<<
 *             ref_window_start = 0
 *         ref_window = fafile.fetch(chrom, ref_window_start, ref_window_end).lower()
 */
  }

  /* "pysamstats/opt.pyx":1504
 *         if ref_window_start < 0:
 *             ref_window_start = 0
 *         ref_window = fafile.fetch(chrom, ref_window_start, ref_window_end).lower()             # <<<<<<<<<<<<<<
 *         if len(ref_window) == 0:
 *             gc = -1
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_fafile), __pyx_n_s_fetch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1504, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_chrom, __pyx_v_ref_window_start, __pyx_v_ref_window_end};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1504, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_chrom, __pyx_v_ref_window_start, __pyx_v_ref_window_end};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1504, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1504, __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(__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_chrom);
    __Pyx_INCREF(__pyx_v_ref_window_start);
    __Pyx_GIVEREF(__pyx_v_ref_window_start);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_ref_window_start);
    __Pyx_INCREF(__pyx_v_ref_window_end);
    __Pyx_GIVEREF(__pyx_v_ref_window_end);
    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_ref_window_end);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1504, __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_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1504, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1504, __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_ERR(0, 1504, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_ref_window = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1505
 *             ref_window_start = 0
 *         ref_window = fafile.fetch(chrom, ref_window_start, ref_window_end).lower()
 *         if len(ref_window) == 0:             # <<<<<<<<<<<<<<
 *             gc = -1
 *         else:
 */
  __pyx_t_8 = PyObject_Length(__pyx_v_ref_window); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 1505, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_8 == 0) != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":1506
 *         ref_window = fafile.fetch(chrom, ref_window_start, ref_window_end).lower()
 *         if len(ref_window) == 0:
 *             gc = -1             # <<<<<<<<<<<<<<
 *         else:
 *             gc = gc_content(ref_window)
 */
    __pyx_v_gc = -1L;

    /* "pysamstats/opt.pyx":1505
 *             ref_window_start = 0
 *         ref_window = fafile.fetch(chrom, ref_window_start, ref_window_end).lower()
 *         if len(ref_window) == 0:             # <<<<<<<<<<<<<<
 *             gc = -1
 *         else:
 */
    goto __pyx_L4;
  }

  /* "pysamstats/opt.pyx":1508
 *             gc = -1
 *         else:
 *             gc = gc_content(ref_window)             # <<<<<<<<<<<<<<
 * 
 *         # make record
 */
  /*else*/ {
    __pyx_t_6 = __pyx_f_10pysamstats_3opt_gc_content(__pyx_v_ref_window); if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 1508, __pyx_L1_error)
    __pyx_v_gc = __pyx_t_6;
  }
  __pyx_L4:;

  /* "pysamstats/opt.pyx":1511
 * 
 *         # make record
 *         rec = {'reads_all': self.reads.all,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.reads.pp,
 *                'gc': gc}
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->reads->all); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_4) < 0) __PYX_ERR(0, 1511, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pysamstats/opt.pyx":1512
 *         # make record
 *         rec = {'reads_all': self.reads.all,
 *                'reads_pp': self.reads.pp,             # <<<<<<<<<<<<<<
 *                'gc': gc}
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->reads->pp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_4) < 0) __PYX_ERR(0, 1511, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pysamstats/opt.pyx":1513
 *         rec = {'reads_all': self.reads.all,
 *                'reads_pp': self.reads.pp,
 *                'gc': gc}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_gc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_gc, __pyx_t_4) < 0) __PYX_ERR(0, 1511, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1516
 * 
 *         # reset counters
 *         self.reset()             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1516, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1516, __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_ERR(0, 1516, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1518
 *         self.reset()
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1497
 *         self.reads.incr(is_proper_pair)
 * 
 *     cdef dict rec(self, chrom, pos, FastaFile fafile, bytes refbase):             # <<<<<<<<<<<<<<
 * 
 *         # compute GC
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysamstats.opt.CoverageGC.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref_window_start);
  __Pyx_XDECREF(__pyx_v_ref_window_end);
  __Pyx_XDECREF(__pyx_v_ref_window);
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1526
 * 
 * 
 * cdef int gc_content(ref_window) except -1:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n
 *     cdef char* seq
 */

static int __pyx_f_10pysamstats_3opt_gc_content(PyObject *__pyx_v_ref_window) {
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_n;
  char *__pyx_v_seq;
  int __pyx_v_gc_count;
  PyObject *__pyx_v_gc = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  char *__pyx_t_6;
  Py_ssize_t __pyx_t_7;
  double __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("gc_content", 0);
  __Pyx_INCREF(__pyx_v_ref_window);

  /* "pysamstats/opt.pyx":1529
 *     cdef Py_ssize_t i, n
 *     cdef char* seq
 *     cdef int gc_count = 0             # <<<<<<<<<<<<<<
 *     n = len(ref_window)
 *     if not PY2:
 */
  __pyx_v_gc_count = 0;

  /* "pysamstats/opt.pyx":1530
 *     cdef char* seq
 *     cdef int gc_count = 0
 *     n = len(ref_window)             # <<<<<<<<<<<<<<
 *     if not PY2:
 *         ref_window = ref_window.encode('ascii')
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_ref_window); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(0, 1530, __pyx_L1_error)
  __pyx_v_n = __pyx_t_1;

  /* "pysamstats/opt.pyx":1531
 *     cdef int gc_count = 0
 *     n = len(ref_window)
 *     if not PY2:             # <<<<<<<<<<<<<<
 *         ref_window = ref_window.encode('ascii')
 *     seq = ref_window
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1531, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1531, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = ((!__pyx_t_3) != 0);
  if (__pyx_t_4) {

    /* "pysamstats/opt.pyx":1532
 *     n = len(ref_window)
 *     if not PY2:
 *         ref_window = ref_window.encode('ascii')             # <<<<<<<<<<<<<<
 *     seq = ref_window
 *     for i in range(n):
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ref_window, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_ref_window, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "pysamstats/opt.pyx":1531
 *     cdef int gc_count = 0
 *     n = len(ref_window)
 *     if not PY2:             # <<<<<<<<<<<<<<
 *         ref_window = ref_window.encode('ascii')
 *     seq = ref_window
 */
  }

  /* "pysamstats/opt.pyx":1533
 *     if not PY2:
 *         ref_window = ref_window.encode('ascii')
 *     seq = ref_window             # <<<<<<<<<<<<<<
 *     for i in range(n):
 *         if seq[i] == b'g' or seq[i] == b'c':
 */
  __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_ref_window); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 1533, __pyx_L1_error)
  __pyx_v_seq = __pyx_t_6;

  /* "pysamstats/opt.pyx":1534
 *         ref_window = ref_window.encode('ascii')
 *     seq = ref_window
 *     for i in range(n):             # <<<<<<<<<<<<<<
 *         if seq[i] == b'g' or seq[i] == b'c':
 *             gc_count += 1
 */
  __pyx_t_1 = __pyx_v_n;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_1; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "pysamstats/opt.pyx":1535
 *     seq = ref_window
 *     for i in range(n):
 *         if seq[i] == b'g' or seq[i] == b'c':             # <<<<<<<<<<<<<<
 *             gc_count += 1
 *     gc = int(round(gc_count * 100. / n))
 */
    __pyx_t_3 = (((__pyx_v_seq[__pyx_v_i]) == 'g') != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_3 = (((__pyx_v_seq[__pyx_v_i]) == 'c') != 0);
    __pyx_t_4 = __pyx_t_3;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_4) {

      /* "pysamstats/opt.pyx":1536
 *     for i in range(n):
 *         if seq[i] == b'g' or seq[i] == b'c':
 *             gc_count += 1             # <<<<<<<<<<<<<<
 *     gc = int(round(gc_count * 100. / n))
 *     return gc
 */
      __pyx_v_gc_count = (__pyx_v_gc_count + 1);

      /* "pysamstats/opt.pyx":1535
 *     seq = ref_window
 *     for i in range(n):
 *         if seq[i] == b'g' or seq[i] == b'c':             # <<<<<<<<<<<<<<
 *             gc_count += 1
 *     gc = int(round(gc_count * 100. / n))
 */
    }
  }

  /* "pysamstats/opt.pyx":1537
 *         if seq[i] == b'g' or seq[i] == b'c':
 *             gc_count += 1
 *     gc = int(round(gc_count * 100. / n))             # <<<<<<<<<<<<<<
 *     return gc
 * 
 */
  __pyx_t_8 = (__pyx_v_gc_count * 100.);
  if (unlikely(__pyx_v_n == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(0, 1537, __pyx_L1_error)
  }
  __pyx_t_5 = PyFloat_FromDouble((__pyx_t_8 / ((double)__pyx_v_n))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_round, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_gc = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1538
 *             gc_count += 1
 *     gc = int(round(gc_count * 100. / n))
 *     return gc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_gc); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1538, __pyx_L1_error)
  __pyx_r = __pyx_t_9;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1526
 * 
 * 
 * cdef int gc_content(ref_window) except -1:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t i, n
 *     cdef char* seq
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("pysamstats.opt.gc_content", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gc);
  __Pyx_XDECREF(__pyx_v_ref_window);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1543
 * cdef class BinnedStat(object):
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 *         return dict()
 * 
 */

static PyObject *__pyx_f_10pysamstats_3opt_10BinnedStat_rec(CYTHON_UNUSED struct __pyx_obj_10pysamstats_3opt_BinnedStat *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_bin_start, CYTHON_UNUSED PyObject *__pyx_v_bin_end, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1544
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):
 *         return dict()             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam1_t* b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1543
 * cdef class BinnedStat(object):
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 *         return dict()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("pysamstats.opt.BinnedStat.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1546
 *         return dict()
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static void __pyx_f_10pysamstats_3opt_10BinnedStat_recv(CYTHON_UNUSED struct __pyx_obj_10pysamstats_3opt_BinnedStat *__pyx_v_self, CYTHON_UNUSED bam1_t *__pyx_v_b) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("recv", 0);

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

/* "pysamstats/opt.pyx":1554
 *     cdef int reads_all, reads_pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = self.reads_pp = 0
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_14CoverageBinned___init__(struct __pyx_obj_10pysamstats_3opt_CoverageBinned *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1555
 * 
 *     def __init__(self):
 *         self.reads_all = self.reads_pp = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):
 */
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->reads_pp = 0;

  /* "pysamstats/opt.pyx":1554
 *     cdef int reads_all, reads_pp
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = self.reads_pp = 0
 * 
 */

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

/* "pysamstats/opt.pyx":1557
 *         self.reads_all = self.reads_pp = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # determine %GC
 */

static PyObject *__pyx_f_10pysamstats_3opt_14CoverageBinned_rec(struct __pyx_obj_10pysamstats_3opt_CoverageBinned *__pyx_v_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_bin_start, PyObject *__pyx_v_bin_end, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile) {
  PyObject *__pyx_v_ref_window = NULL;
  int __pyx_v_gc;
  PyObject *__pyx_v_rec = 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;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1560
 * 
 *         # determine %GC
 *         ref_window = fafile.fetch(chrom, bin_start, bin_end).lower()             # <<<<<<<<<<<<<<
 *         gc = gc_content(ref_window)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_fafile), __pyx_n_s_fetch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_chrom, __pyx_v_bin_start, __pyx_v_bin_end};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1560, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_chrom, __pyx_v_bin_start, __pyx_v_bin_end};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1560, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1560, __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_v_chrom);
    __Pyx_GIVEREF(__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_chrom);
    __Pyx_INCREF(__pyx_v_bin_start);
    __Pyx_GIVEREF(__pyx_v_bin_start);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_bin_start);
    __Pyx_INCREF(__pyx_v_bin_end);
    __Pyx_GIVEREF(__pyx_v_bin_end);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_bin_end);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1560, __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_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1560, __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_ERR(0, 1560, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_ref_window = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1561
 *         # determine %GC
 *         ref_window = fafile.fetch(chrom, bin_start, bin_end).lower()
 *         gc = gc_content(ref_window)             # <<<<<<<<<<<<<<
 * 
 *         # make record for bin
 */
  __pyx_t_5 = __pyx_f_10pysamstats_3opt_gc_content(__pyx_v_ref_window); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1561, __pyx_L1_error)
  __pyx_v_gc = __pyx_t_5;

  /* "pysamstats/opt.pyx":1564
 * 
 *         # make record for bin
 *         rec = {'gc': gc,             # <<<<<<<<<<<<<<
 *                'reads_all': self.reads_all,
 *                'reads_pp': self.reads_pp}
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_gc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_gc, __pyx_t_3) < 0) __PYX_ERR(0, 1564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1565
 *         # make record for bin
 *         rec = {'gc': gc,
 *                'reads_all': self.reads_all,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.reads_pp}
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_3) < 0) __PYX_ERR(0, 1564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1566
 *         rec = {'gc': gc,
 *                'reads_all': self.reads_all,
 *                'reads_pp': self.reads_pp}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_pp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1566, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_3) < 0) __PYX_ERR(0, 1564, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1569
 * 
 *         # reset counters
 *         self.reads_all = self.reads_pp = 0             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->reads_pp = 0;

  /* "pysamstats/opt.pyx":1571
 *         self.reads_all = self.reads_pp = 0
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam1_t* b):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1557
 *         self.reads_all = self.reads_pp = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # determine %GC
 */

  /* 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("pysamstats.opt.CoverageBinned.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref_window);
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1573
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

static void __pyx_f_10pysamstats_3opt_14CoverageBinned_recv(struct __pyx_obj_10pysamstats_3opt_CoverageBinned *__pyx_v_self, bam1_t *__pyx_v_b) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_unmapped;
  int __pyx_v_is_proper_pair;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1577
 *         cdef bint is_unmapped
 *         cdef bint is_proper_pair
 *         flag = b.core.flag             # <<<<<<<<<<<<<<
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 */
  __pyx_t_1 = __pyx_v_b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1578
 *         cdef bint is_proper_pair
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)             # <<<<<<<<<<<<<<
 *         if not is_unmapped:
 *             self.reads_all += 1
 */
  __pyx_v_is_unmapped = ((__pyx_v_flag & 4) != 0);

  /* "pysamstats/opt.pyx":1579
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 */
  __pyx_t_2 = ((!(__pyx_v_is_unmapped != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1580
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 *             self.reads_all += 1             # <<<<<<<<<<<<<<
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             if is_proper_pair:
 */
    __pyx_v_self->reads_all = (__pyx_v_self->reads_all + 1);

    /* "pysamstats/opt.pyx":1581
 *         if not is_unmapped:
 *             self.reads_all += 1
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *             if is_proper_pair:
 *                 self.reads_pp += 1
 */
    __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

    /* "pysamstats/opt.pyx":1582
 *             self.reads_all += 1
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.reads_pp += 1
 * 
 */
    __pyx_t_2 = (__pyx_v_is_proper_pair != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1583
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             if is_proper_pair:
 *                 self.reads_pp += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_self->reads_pp = (__pyx_v_self->reads_pp + 1);

      /* "pysamstats/opt.pyx":1582
 *             self.reads_all += 1
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.reads_pp += 1
 * 
 */
    }

    /* "pysamstats/opt.pyx":1579
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 */
  }

  /* "pysamstats/opt.pyx":1573
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

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

/* "pysamstats/opt.pyx":1597
 *         reads_duplicate
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = self.reads_pp = self.reads_mate_unmapped \
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\
 */

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

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

static int __pyx_pf_10pysamstats_3opt_17CoverageExtBinned___init__(struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1598
 * 
 *     def __init__(self):
 *         self.reads_all = self.reads_pp = self.reads_mate_unmapped \             # <<<<<<<<<<<<<<
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\
 *             = self.reads_faceaway = self.reads_softclipped \
 */
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->reads_pp = 0;
  __pyx_v_self->reads_mate_unmapped = 0;

  /* "pysamstats/opt.pyx":1599
 *     def __init__(self):
 *         self.reads_all = self.reads_pp = self.reads_mate_unmapped \
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\             # <<<<<<<<<<<<<<
 *             = self.reads_faceaway = self.reads_softclipped \
 *             = self.reads_duplicate = 0
 */
  __pyx_v_self->reads_mate_other_chr = 0;
  __pyx_v_self->reads_mate_same_strand = 0;

  /* "pysamstats/opt.pyx":1600
 *         self.reads_all = self.reads_pp = self.reads_mate_unmapped \
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\
 *             = self.reads_faceaway = self.reads_softclipped \             # <<<<<<<<<<<<<<
 *             = self.reads_duplicate = 0
 * 
 */
  __pyx_v_self->reads_faceaway = 0;
  __pyx_v_self->reads_softclipped = 0;

  /* "pysamstats/opt.pyx":1601
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\
 *             = self.reads_faceaway = self.reads_softclipped \
 *             = self.reads_duplicate = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):
 */
  __pyx_v_self->reads_duplicate = 0;

  /* "pysamstats/opt.pyx":1597
 *         reads_duplicate
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = self.reads_pp = self.reads_mate_unmapped \
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\
 */

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

/* "pysamstats/opt.pyx":1603
 *             = self.reads_duplicate = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # determine %GC
 */

static PyObject *__pyx_f_10pysamstats_3opt_17CoverageExtBinned_rec(struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned *__pyx_v_self, PyObject *__pyx_v_chrom, PyObject *__pyx_v_bin_start, PyObject *__pyx_v_bin_end, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile) {
  PyObject *__pyx_v_ref_window = NULL;
  int __pyx_v_gc;
  PyObject *__pyx_v_rec = 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;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1606
 * 
 *         # determine %GC
 *         ref_window = fafile.fetch(chrom, bin_start, bin_end).lower()             # <<<<<<<<<<<<<<
 *         gc = gc_content(ref_window)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_fafile), __pyx_n_s_fetch); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_chrom, __pyx_v_bin_start, __pyx_v_bin_end};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1606, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_chrom, __pyx_v_bin_start, __pyx_v_bin_end};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1606, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1606, __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_v_chrom);
    __Pyx_GIVEREF(__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_chrom);
    __Pyx_INCREF(__pyx_v_bin_start);
    __Pyx_GIVEREF(__pyx_v_bin_start);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_bin_start);
    __Pyx_INCREF(__pyx_v_bin_end);
    __Pyx_GIVEREF(__pyx_v_bin_end);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_bin_end);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1606, __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_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_ERR(0, 1606, __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_ERR(0, 1606, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_ref_window = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1607
 *         # determine %GC
 *         ref_window = fafile.fetch(chrom, bin_start, bin_end).lower()
 *         gc = gc_content(ref_window)             # <<<<<<<<<<<<<<
 * 
 *         # make record for bin
 */
  __pyx_t_5 = __pyx_f_10pysamstats_3opt_gc_content(__pyx_v_ref_window); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 1607, __pyx_L1_error)
  __pyx_v_gc = __pyx_t_5;

  /* "pysamstats/opt.pyx":1610
 * 
 *         # make record for bin
 *         rec = {'gc': gc,             # <<<<<<<<<<<<<<
 *                'reads_all': self.reads_all,
 *                'reads_pp': self.reads_pp,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_gc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_gc, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1611
 *         # make record for bin
 *         rec = {'gc': gc,
 *                'reads_all': self.reads_all,             # <<<<<<<<<<<<<<
 *                'reads_pp': self.reads_pp,
 *                'reads_mate_unmapped': self.reads_mate_unmapped,
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1611, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1612
 *         rec = {'gc': gc,
 *                'reads_all': self.reads_all,
 *                'reads_pp': self.reads_pp,             # <<<<<<<<<<<<<<
 *                'reads_mate_unmapped': self.reads_mate_unmapped,
 *                'reads_mate_other_chr': self.reads_mate_other_chr,
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_pp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1613
 *                'reads_all': self.reads_all,
 *                'reads_pp': self.reads_pp,
 *                'reads_mate_unmapped': self.reads_mate_unmapped,             # <<<<<<<<<<<<<<
 *                'reads_mate_other_chr': self.reads_mate_other_chr,
 *                'reads_mate_same_strand': self.reads_mate_same_strand,
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_mate_unmapped); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_unmapped, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1614
 *                'reads_pp': self.reads_pp,
 *                'reads_mate_unmapped': self.reads_mate_unmapped,
 *                'reads_mate_other_chr': self.reads_mate_other_chr,             # <<<<<<<<<<<<<<
 *                'reads_mate_same_strand': self.reads_mate_same_strand,
 *                'reads_faceaway': self.reads_faceaway,
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_mate_other_chr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1614, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_other_chr, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1615
 *                'reads_mate_unmapped': self.reads_mate_unmapped,
 *                'reads_mate_other_chr': self.reads_mate_other_chr,
 *                'reads_mate_same_strand': self.reads_mate_same_strand,             # <<<<<<<<<<<<<<
 *                'reads_faceaway': self.reads_faceaway,
 *                'reads_softclipped': self.reads_softclipped,
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_mate_same_strand); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mate_same_strand, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1616
 *                'reads_mate_other_chr': self.reads_mate_other_chr,
 *                'reads_mate_same_strand': self.reads_mate_same_strand,
 *                'reads_faceaway': self.reads_faceaway,             # <<<<<<<<<<<<<<
 *                'reads_softclipped': self.reads_softclipped,
 *                'reads_duplicate': self.reads_duplicate}
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_faceaway); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1616, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_faceaway, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1617
 *                'reads_mate_same_strand': self.reads_mate_same_strand,
 *                'reads_faceaway': self.reads_faceaway,
 *                'reads_softclipped': self.reads_softclipped,             # <<<<<<<<<<<<<<
 *                'reads_duplicate': self.reads_duplicate}
 * 
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_softclipped); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_softclipped, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1618
 *                'reads_faceaway': self.reads_faceaway,
 *                'reads_softclipped': self.reads_softclipped,
 *                'reads_duplicate': self.reads_duplicate}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->reads_duplicate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1618, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_duplicate, __pyx_t_3) < 0) __PYX_ERR(0, 1610, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1621
 * 
 *         # reset counters
 *         self.reads_all = self.reads_pp = self.reads_mate_unmapped \             # <<<<<<<<<<<<<<
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\
 *             = self.reads_faceaway = self.reads_softclipped \
 */
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->reads_pp = 0;
  __pyx_v_self->reads_mate_unmapped = 0;

  /* "pysamstats/opt.pyx":1622
 *         # reset counters
 *         self.reads_all = self.reads_pp = self.reads_mate_unmapped \
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\             # <<<<<<<<<<<<<<
 *             = self.reads_faceaway = self.reads_softclipped \
 *             = self.reads_duplicate = 0
 */
  __pyx_v_self->reads_mate_other_chr = 0;
  __pyx_v_self->reads_mate_same_strand = 0;

  /* "pysamstats/opt.pyx":1623
 *         self.reads_all = self.reads_pp = self.reads_mate_unmapped \
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\
 *             = self.reads_faceaway = self.reads_softclipped \             # <<<<<<<<<<<<<<
 *             = self.reads_duplicate = 0
 * 
 */
  __pyx_v_self->reads_faceaway = 0;
  __pyx_v_self->reads_softclipped = 0;

  /* "pysamstats/opt.pyx":1624
 *             = self.reads_mate_other_chr = self.reads_mate_same_strand\
 *             = self.reads_faceaway = self.reads_softclipped \
 *             = self.reads_duplicate = 0             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_v_self->reads_duplicate = 0;

  /* "pysamstats/opt.pyx":1626
 *             = self.reads_duplicate = 0
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam1_t* b):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1603
 *             = self.reads_duplicate = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # determine %GC
 */

  /* 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("pysamstats.opt.CoverageExtBinned.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ref_window);
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1628
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

static void __pyx_f_10pysamstats_3opt_17CoverageExtBinned_recv(struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned *__pyx_v_self, bam1_t *__pyx_v_b) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_unmapped;
  int __pyx_v_is_reverse;
  int __pyx_v_is_proper_pair;
  int __pyx_v_is_duplicate;
  int __pyx_v_mate_is_reverse;
  int __pyx_v_tlen;
  int __pyx_v_mate_is_unmapped;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  int32_t __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1637
 *         cdef bint mate_is_reverse
 *         cdef int tlen
 *         flag = b.core.flag             # <<<<<<<<<<<<<<
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 */
  __pyx_t_1 = __pyx_v_b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1638
 *         cdef int tlen
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)             # <<<<<<<<<<<<<<
 *         if not is_unmapped:
 *             self.reads_all += 1
 */
  __pyx_v_is_unmapped = ((__pyx_v_flag & 4) != 0);

  /* "pysamstats/opt.pyx":1639
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 *             is_reverse = <bint>(flag & BAM_FREVERSE)
 */
  __pyx_t_2 = ((!(__pyx_v_is_unmapped != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1640
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 *             self.reads_all += 1             # <<<<<<<<<<<<<<
 *             is_reverse = <bint>(flag & BAM_FREVERSE)
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 */
    __pyx_v_self->reads_all = (__pyx_v_self->reads_all + 1);

    /* "pysamstats/opt.pyx":1641
 *         if not is_unmapped:
 *             self.reads_all += 1
 *             is_reverse = <bint>(flag & BAM_FREVERSE)             # <<<<<<<<<<<<<<
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             is_duplicate = <bint>(flag & BAM_FDUP)
 */
    __pyx_v_is_reverse = ((__pyx_v_flag & 16) != 0);

    /* "pysamstats/opt.pyx":1642
 *             self.reads_all += 1
 *             is_reverse = <bint>(flag & BAM_FREVERSE)
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *             is_duplicate = <bint>(flag & BAM_FDUP)
 *             mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 */
    __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

    /* "pysamstats/opt.pyx":1643
 *             is_reverse = <bint>(flag & BAM_FREVERSE)
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             is_duplicate = <bint>(flag & BAM_FDUP)             # <<<<<<<<<<<<<<
 *             mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *             mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 */
    __pyx_v_is_duplicate = ((__pyx_v_flag & 0x400) != 0);

    /* "pysamstats/opt.pyx":1644
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             is_duplicate = <bint>(flag & BAM_FDUP)
 *             mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)             # <<<<<<<<<<<<<<
 *             mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 *             tlen = b.core.isize
 */
    __pyx_v_mate_is_unmapped = ((__pyx_v_flag & 8) != 0);

    /* "pysamstats/opt.pyx":1645
 *             is_duplicate = <bint>(flag & BAM_FDUP)
 *             mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *             mate_is_reverse = <bint>(flag & BAM_FMREVERSE)             # <<<<<<<<<<<<<<
 *             tlen = b.core.isize
 *             if is_duplicate:
 */
    __pyx_v_mate_is_reverse = ((__pyx_v_flag & 32) != 0);

    /* "pysamstats/opt.pyx":1646
 *             mate_is_unmapped = <bint>(flag & BAM_FMUNMAP)
 *             mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 *             tlen = b.core.isize             # <<<<<<<<<<<<<<
 *             if is_duplicate:
 *                 self.reads_duplicate += 1
 */
    __pyx_t_3 = __pyx_v_b->core.isize;
    __pyx_v_tlen = __pyx_t_3;

    /* "pysamstats/opt.pyx":1647
 *             mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 *             tlen = b.core.isize
 *             if is_duplicate:             # <<<<<<<<<<<<<<
 *                 self.reads_duplicate += 1
 *             if is_proper_pair:
 */
    __pyx_t_2 = (__pyx_v_is_duplicate != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1648
 *             tlen = b.core.isize
 *             if is_duplicate:
 *                 self.reads_duplicate += 1             # <<<<<<<<<<<<<<
 *             if is_proper_pair:
 *                 self.reads_pp += 1
 */
      __pyx_v_self->reads_duplicate = (__pyx_v_self->reads_duplicate + 1);

      /* "pysamstats/opt.pyx":1647
 *             mate_is_reverse = <bint>(flag & BAM_FMREVERSE)
 *             tlen = b.core.isize
 *             if is_duplicate:             # <<<<<<<<<<<<<<
 *                 self.reads_duplicate += 1
 *             if is_proper_pair:
 */
    }

    /* "pysamstats/opt.pyx":1649
 *             if is_duplicate:
 *                 self.reads_duplicate += 1
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.reads_pp += 1
 *             if mate_is_unmapped:
 */
    __pyx_t_2 = (__pyx_v_is_proper_pair != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1650
 *                 self.reads_duplicate += 1
 *             if is_proper_pair:
 *                 self.reads_pp += 1             # <<<<<<<<<<<<<<
 *             if mate_is_unmapped:
 *                 self.reads_mate_unmapped += 1
 */
      __pyx_v_self->reads_pp = (__pyx_v_self->reads_pp + 1);

      /* "pysamstats/opt.pyx":1649
 *             if is_duplicate:
 *                 self.reads_duplicate += 1
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.reads_pp += 1
 *             if mate_is_unmapped:
 */
    }

    /* "pysamstats/opt.pyx":1651
 *             if is_proper_pair:
 *                 self.reads_pp += 1
 *             if mate_is_unmapped:             # <<<<<<<<<<<<<<
 *                 self.reads_mate_unmapped += 1
 *             elif b.core.tid != b.core.mtid:
 */
    __pyx_t_2 = (__pyx_v_mate_is_unmapped != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1652
 *                 self.reads_pp += 1
 *             if mate_is_unmapped:
 *                 self.reads_mate_unmapped += 1             # <<<<<<<<<<<<<<
 *             elif b.core.tid != b.core.mtid:
 *                 self.reads_mate_other_chr += 1
 */
      __pyx_v_self->reads_mate_unmapped = (__pyx_v_self->reads_mate_unmapped + 1);

      /* "pysamstats/opt.pyx":1651
 *             if is_proper_pair:
 *                 self.reads_pp += 1
 *             if mate_is_unmapped:             # <<<<<<<<<<<<<<
 *                 self.reads_mate_unmapped += 1
 *             elif b.core.tid != b.core.mtid:
 */
      goto __pyx_L6;
    }

    /* "pysamstats/opt.pyx":1653
 *             if mate_is_unmapped:
 *                 self.reads_mate_unmapped += 1
 *             elif b.core.tid != b.core.mtid:             # <<<<<<<<<<<<<<
 *                 self.reads_mate_other_chr += 1
 *             elif (is_reverse and mate_is_reverse) \
 */
    __pyx_t_2 = ((__pyx_v_b->core.tid != __pyx_v_b->core.mtid) != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1654
 *                 self.reads_mate_unmapped += 1
 *             elif b.core.tid != b.core.mtid:
 *                 self.reads_mate_other_chr += 1             # <<<<<<<<<<<<<<
 *             elif (is_reverse and mate_is_reverse) \
 *                     or (not is_reverse and not mate_is_reverse):
 */
      __pyx_v_self->reads_mate_other_chr = (__pyx_v_self->reads_mate_other_chr + 1);

      /* "pysamstats/opt.pyx":1653
 *             if mate_is_unmapped:
 *                 self.reads_mate_unmapped += 1
 *             elif b.core.tid != b.core.mtid:             # <<<<<<<<<<<<<<
 *                 self.reads_mate_other_chr += 1
 *             elif (is_reverse and mate_is_reverse) \
 */
      goto __pyx_L6;
    }

    /* "pysamstats/opt.pyx":1655
 *             elif b.core.tid != b.core.mtid:
 *                 self.reads_mate_other_chr += 1
 *             elif (is_reverse and mate_is_reverse) \             # <<<<<<<<<<<<<<
 *                     or (not is_reverse and not mate_is_reverse):
 *                 self.reads_mate_same_strand += 1
 */
    __pyx_t_4 = (__pyx_v_is_reverse != 0);
    if (!__pyx_t_4) {
      goto __pyx_L8_next_or;
    } else {
    }
    __pyx_t_4 = (__pyx_v_mate_is_reverse != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_L8_next_or:;

    /* "pysamstats/opt.pyx":1656
 *                 self.reads_mate_other_chr += 1
 *             elif (is_reverse and mate_is_reverse) \
 *                     or (not is_reverse and not mate_is_reverse):             # <<<<<<<<<<<<<<
 *                 self.reads_mate_same_strand += 1
 *             elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 */
    __pyx_t_4 = ((!(__pyx_v_is_reverse != 0)) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_4 = ((!(__pyx_v_mate_is_reverse != 0)) != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L7_bool_binop_done:;

    /* "pysamstats/opt.pyx":1655
 *             elif b.core.tid != b.core.mtid:
 *                 self.reads_mate_other_chr += 1
 *             elif (is_reverse and mate_is_reverse) \             # <<<<<<<<<<<<<<
 *                     or (not is_reverse and not mate_is_reverse):
 *                 self.reads_mate_same_strand += 1
 */
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1657
 *             elif (is_reverse and mate_is_reverse) \
 *                     or (not is_reverse and not mate_is_reverse):
 *                 self.reads_mate_same_strand += 1             # <<<<<<<<<<<<<<
 *             elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *                 self.reads_faceaway += 1
 */
      __pyx_v_self->reads_mate_same_strand = (__pyx_v_self->reads_mate_same_strand + 1);

      /* "pysamstats/opt.pyx":1655
 *             elif b.core.tid != b.core.mtid:
 *                 self.reads_mate_other_chr += 1
 *             elif (is_reverse and mate_is_reverse) \             # <<<<<<<<<<<<<<
 *                     or (not is_reverse and not mate_is_reverse):
 *                 self.reads_mate_same_strand += 1
 */
      goto __pyx_L6;
    }

    /* "pysamstats/opt.pyx":1658
 *                     or (not is_reverse and not mate_is_reverse):
 *                 self.reads_mate_same_strand += 1
 *             elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):             # <<<<<<<<<<<<<<
 *                 self.reads_faceaway += 1
 *             if is_softclipped(b):
 */
    __pyx_t_4 = (__pyx_v_is_reverse != 0);
    if (!__pyx_t_4) {
      goto __pyx_L12_next_or;
    } else {
    }
    __pyx_t_4 = ((__pyx_v_tlen > 0) != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_L12_next_or:;
    __pyx_t_4 = ((!(__pyx_v_is_reverse != 0)) != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_2 = __pyx_t_4;
      goto __pyx_L11_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_tlen < 0) != 0);
    __pyx_t_2 = __pyx_t_4;
    __pyx_L11_bool_binop_done:;
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1659
 *                 self.reads_mate_same_strand += 1
 *             elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *                 self.reads_faceaway += 1             # <<<<<<<<<<<<<<
 *             if is_softclipped(b):
 *                 self.reads_softclipped += 1
 */
      __pyx_v_self->reads_faceaway = (__pyx_v_self->reads_faceaway + 1);

      /* "pysamstats/opt.pyx":1658
 *                     or (not is_reverse and not mate_is_reverse):
 *                 self.reads_mate_same_strand += 1
 *             elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):             # <<<<<<<<<<<<<<
 *                 self.reads_faceaway += 1
 *             if is_softclipped(b):
 */
    }
    __pyx_L6:;

    /* "pysamstats/opt.pyx":1660
 *             elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *                 self.reads_faceaway += 1
 *             if is_softclipped(b):             # <<<<<<<<<<<<<<
 *                 self.reads_softclipped += 1
 * 
 */
    __pyx_t_2 = (__pyx_f_10pysamstats_3opt_is_softclipped(__pyx_v_b) != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1661
 *                 self.reads_faceaway += 1
 *             if is_softclipped(b):
 *                 self.reads_softclipped += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_self->reads_softclipped = (__pyx_v_self->reads_softclipped + 1);

      /* "pysamstats/opt.pyx":1660
 *             elif (is_reverse and tlen > 0) or (not is_reverse and tlen < 0):
 *                 self.reads_faceaway += 1
 *             if is_softclipped(b):             # <<<<<<<<<<<<<<
 *                 self.reads_softclipped += 1
 * 
 */
    }

    /* "pysamstats/opt.pyx":1639
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 *             is_reverse = <bint>(flag & BAM_FREVERSE)
 */
  }

  /* "pysamstats/opt.pyx":1628
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

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

/* "pysamstats/opt.pyx":1674
 *     cdef uint64_t mapq, mapq_squared_sum
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = self.reads_mapq0 = self.mapq_squared_sum = 0
 * 
 */

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

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

static int __pyx_pf_10pysamstats_3opt_10MapqBinned___init__(struct __pyx_obj_10pysamstats_3opt_MapqBinned *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1675
 * 
 *     def __init__(self):
 *         self.reads_all = self.reads_mapq0 = self.mapq_squared_sum = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):
 */
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->reads_mapq0 = 0;
  __pyx_v_self->mapq_squared_sum = 0;

  /* "pysamstats/opt.pyx":1674
 *     cdef uint64_t mapq, mapq_squared_sum
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = self.reads_mapq0 = self.mapq_squared_sum = 0
 * 
 */

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

/* "pysamstats/opt.pyx":1677
 *         self.reads_all = self.reads_mapq0 = self.mapq_squared_sum = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # make record for bin
 */

static PyObject *__pyx_f_10pysamstats_3opt_10MapqBinned_rec(struct __pyx_obj_10pysamstats_3opt_MapqBinned *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_bin_start, CYTHON_UNUSED PyObject *__pyx_v_bin_end, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile) {
  PyObject *__pyx_v_rec = 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;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1680
 * 
 *         # make record for bin
 *         rec = {'reads_all': self.reads_all,             # <<<<<<<<<<<<<<
 *                'reads_mapq0': self.reads_mapq0,
 *                'rms_mapq': rootmean(self.mapq_squared_sum, self.reads_all)}
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1681
 *         # make record for bin
 *         rec = {'reads_all': self.reads_all,
 *                'reads_mapq0': self.reads_mapq0,             # <<<<<<<<<<<<<<
 *                'rms_mapq': rootmean(self.mapq_squared_sum, self.reads_all)}
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_mapq0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_mapq0, __pyx_t_2) < 0) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1682
 *         rec = {'reads_all': self.reads_all,
 *                'reads_mapq0': self.reads_mapq0,
 *                'rms_mapq': rootmean(self.mapq_squared_sum, self.reads_all)}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_rootmean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_uint64_t(__pyx_v_self->mapq_squared_sum); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_mapq, __pyx_t_2) < 0) __PYX_ERR(0, 1680, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1685
 * 
 *         # reset counters
 *         self.reads_all = self.reads_mapq0 = self.mapq_squared_sum = 0             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->reads_mapq0 = 0;
  __pyx_v_self->mapq_squared_sum = 0;

  /* "pysamstats/opt.pyx":1687
 *         self.reads_all = self.reads_mapq0 = self.mapq_squared_sum = 0
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam1_t* b):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1677
 *         self.reads_all = self.reads_mapq0 = self.mapq_squared_sum = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # make record for bin
 */

  /* 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_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysamstats.opt.MapqBinned.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1689
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

static void __pyx_f_10pysamstats_3opt_10MapqBinned_recv(struct __pyx_obj_10pysamstats_3opt_MapqBinned *__pyx_v_self, bam1_t *__pyx_v_b) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_unmapped;
  uint64_t __pyx_v_mapq;
  uint64_t __pyx_v_mapq_squared;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  uint8_t __pyx_t_3;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1694
 *         cdef uint64_t mapq
 *         cdef uint64_t mapq_squared
 *         flag = b.core.flag             # <<<<<<<<<<<<<<
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 */
  __pyx_t_1 = __pyx_v_b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1695
 *         cdef uint64_t mapq_squared
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)             # <<<<<<<<<<<<<<
 *         if not is_unmapped:
 *             self.reads_all += 1
 */
  __pyx_v_is_unmapped = ((__pyx_v_flag & 4) != 0);

  /* "pysamstats/opt.pyx":1696
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 *             mapq = b.core.qual
 */
  __pyx_t_2 = ((!(__pyx_v_is_unmapped != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1697
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 *             self.reads_all += 1             # <<<<<<<<<<<<<<
 *             mapq = b.core.qual
 *             mapq_squared = mapq**2
 */
    __pyx_v_self->reads_all = (__pyx_v_self->reads_all + 1);

    /* "pysamstats/opt.pyx":1698
 *         if not is_unmapped:
 *             self.reads_all += 1
 *             mapq = b.core.qual             # <<<<<<<<<<<<<<
 *             mapq_squared = mapq**2
 *             self.mapq_squared_sum += mapq_squared
 */
    __pyx_t_3 = __pyx_v_b->core.qual;
    __pyx_v_mapq = __pyx_t_3;

    /* "pysamstats/opt.pyx":1699
 *             self.reads_all += 1
 *             mapq = b.core.qual
 *             mapq_squared = mapq**2             # <<<<<<<<<<<<<<
 *             self.mapq_squared_sum += mapq_squared
 *             if mapq == 0:
 */
    __pyx_v_mapq_squared = __Pyx_pow_uint64_t(__pyx_v_mapq, 2);

    /* "pysamstats/opt.pyx":1700
 *             mapq = b.core.qual
 *             mapq_squared = mapq**2
 *             self.mapq_squared_sum += mapq_squared             # <<<<<<<<<<<<<<
 *             if mapq == 0:
 *                 self.reads_mapq0 += 1
 */
    __pyx_v_self->mapq_squared_sum = (__pyx_v_self->mapq_squared_sum + __pyx_v_mapq_squared);

    /* "pysamstats/opt.pyx":1701
 *             mapq_squared = mapq**2
 *             self.mapq_squared_sum += mapq_squared
 *             if mapq == 0:             # <<<<<<<<<<<<<<
 *                 self.reads_mapq0 += 1
 * 
 */
    __pyx_t_2 = ((__pyx_v_mapq == 0) != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1702
 *             self.mapq_squared_sum += mapq_squared
 *             if mapq == 0:
 *                 self.reads_mapq0 += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_self->reads_mapq0 = (__pyx_v_self->reads_mapq0 + 1);

      /* "pysamstats/opt.pyx":1701
 *             mapq_squared = mapq**2
 *             self.mapq_squared_sum += mapq_squared
 *             if mapq == 0:             # <<<<<<<<<<<<<<
 *                 self.reads_mapq0 += 1
 * 
 */
    }

    /* "pysamstats/opt.pyx":1696
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 *             mapq = b.core.qual
 */
  }

  /* "pysamstats/opt.pyx":1689
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

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

/* "pysamstats/opt.pyx":1714
 *     cdef int reads_all, M, I, D, N, S, H, P, EQ, X
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = self.M = self.I = self.D = self.N = self.S = self.H\
 *             = self.P = self.EQ = self.X = 0
 */

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

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

static int __pyx_pf_10pysamstats_3opt_15AlignmentBinned___init__(struct __pyx_obj_10pysamstats_3opt_AlignmentBinned *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1715
 * 
 *     def __init__(self):
 *         self.reads_all = self.M = self.I = self.D = self.N = self.S = self.H\             # <<<<<<<<<<<<<<
 *             = self.P = self.EQ = self.X = 0
 * 
 */
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->M = 0;
  __pyx_v_self->I = 0;
  __pyx_v_self->D = 0;
  __pyx_v_self->N = 0;
  __pyx_v_self->S = 0;
  __pyx_v_self->H = 0;

  /* "pysamstats/opt.pyx":1716
 *     def __init__(self):
 *         self.reads_all = self.M = self.I = self.D = self.N = self.S = self.H\
 *             = self.P = self.EQ = self.X = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):
 */
  __pyx_v_self->P = 0;
  __pyx_v_self->EQ = 0;
  __pyx_v_self->X = 0;

  /* "pysamstats/opt.pyx":1714
 *     cdef int reads_all, M, I, D, N, S, H, P, EQ, X
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.reads_all = self.M = self.I = self.D = self.N = self.S = self.H\
 *             = self.P = self.EQ = self.X = 0
 */

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

/* "pysamstats/opt.pyx":1718
 *             = self.P = self.EQ = self.X = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # make record for bin
 */

static PyObject *__pyx_f_10pysamstats_3opt_15AlignmentBinned_rec(struct __pyx_obj_10pysamstats_3opt_AlignmentBinned *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_bin_start, CYTHON_UNUSED PyObject *__pyx_v_bin_end, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile) {
  PyObject *__pyx_v_rec = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1721
 * 
 *         # make record for bin
 *         rec = {'reads_all': self.reads_all,             # <<<<<<<<<<<<<<
 *                'M': self.M, 'I': self.I, 'D': self.D, 'N': self.N, 'S': self.S,
 *                'H': self.H, 'P': self.P, '=': self.EQ, 'X': self.X,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1722
 *         # make record for bin
 *         rec = {'reads_all': self.reads_all,
 *                'M': self.M, 'I': self.I, 'D': self.D, 'N': self.N, 'S': self.S,             # <<<<<<<<<<<<<<
 *                'H': self.H, 'P': self.P, '=': self.EQ, 'X': self.X,
 *                'bases_all': self.M + self.I + self.S + self.EQ + self.X}
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->M); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_M, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->I); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_I, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->D); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_D, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_N, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->S); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_S, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1723
 *         rec = {'reads_all': self.reads_all,
 *                'M': self.M, 'I': self.I, 'D': self.D, 'N': self.N, 'S': self.S,
 *                'H': self.H, 'P': self.P, '=': self.EQ, 'X': self.X,             # <<<<<<<<<<<<<<
 *                'bases_all': self.M + self.I + self.S + self.EQ + self.X}
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->H); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_H, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->P); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_P, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->EQ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_s__2, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->X); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_X, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1724
 *                'M': self.M, 'I': self.I, 'D': self.D, 'N': self.N, 'S': self.S,
 *                'H': self.H, 'P': self.P, '=': self.EQ, 'X': self.X,
 *                'bases_all': self.M + self.I + self.S + self.EQ + self.X}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(((((__pyx_v_self->M + __pyx_v_self->I) + __pyx_v_self->S) + __pyx_v_self->EQ) + __pyx_v_self->X)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_bases_all, __pyx_t_2) < 0) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1727
 * 
 *         # reset counters
 *         self.reads_all = self.M = self.I = self.D = self.N = self.S = self.H\             # <<<<<<<<<<<<<<
 *             = self.P = self.EQ = self.X = 0
 * 
 */
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->M = 0;
  __pyx_v_self->I = 0;
  __pyx_v_self->D = 0;
  __pyx_v_self->N = 0;
  __pyx_v_self->S = 0;
  __pyx_v_self->H = 0;

  /* "pysamstats/opt.pyx":1728
 *         # reset counters
 *         self.reads_all = self.M = self.I = self.D = self.N = self.S = self.H\
 *             = self.P = self.EQ = self.X = 0             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_v_self->P = 0;
  __pyx_v_self->EQ = 0;
  __pyx_v_self->X = 0;

  /* "pysamstats/opt.pyx":1730
 *             = self.P = self.EQ = self.X = 0
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam1_t* b):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1718
 *             = self.P = self.EQ = self.X = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # make record for bin
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysamstats.opt.AlignmentBinned.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1732
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

static void __pyx_f_10pysamstats_3opt_15AlignmentBinned_recv(struct __pyx_obj_10pysamstats_3opt_AlignmentBinned *__pyx_v_self, bam1_t *__pyx_v_b) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_unmapped;
  int __pyx_v_k;
  int __pyx_v_op;
  int __pyx_v_l;
  uint32_t *__pyx_v_cigar_p;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  uint32_t __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1736
 *         cdef bint is_unmapped
 *         cdef int k, op, l
 *         flag = b.core.flag             # <<<<<<<<<<<<<<
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 */
  __pyx_t_1 = __pyx_v_b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1737
 *         cdef int k, op, l
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)             # <<<<<<<<<<<<<<
 *         if not is_unmapped:
 *             cigar_p = pysam_bam_get_cigar(b)
 */
  __pyx_v_is_unmapped = ((__pyx_v_flag & 4) != 0);

  /* "pysamstats/opt.pyx":1738
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             cigar_p = pysam_bam_get_cigar(b)
 *             # cigar = list()
 */
  __pyx_t_2 = ((!(__pyx_v_is_unmapped != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1739
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 *             cigar_p = pysam_bam_get_cigar(b)             # <<<<<<<<<<<<<<
 *             # cigar = list()
 *             for k in range(b.core.n_cigar):
 */
    __pyx_v_cigar_p = pysam_bam_get_cigar(__pyx_v_b);

    /* "pysamstats/opt.pyx":1741
 *             cigar_p = pysam_bam_get_cigar(b)
 *             # cigar = list()
 *             for k in range(b.core.n_cigar):             # <<<<<<<<<<<<<<
 *                 op = cigar_p[k] & BAM_CIGAR_MASK
 *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
 */
    __pyx_t_3 = __pyx_v_b->core.n_cigar;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_k = __pyx_t_4;

      /* "pysamstats/opt.pyx":1742
 *             # cigar = list()
 *             for k in range(b.core.n_cigar):
 *                 op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
 *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
 *                 # cigar.append((op, l))
 */
      __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);

      /* "pysamstats/opt.pyx":1743
 *             for k in range(b.core.n_cigar):
 *                 op = cigar_p[k] & BAM_CIGAR_MASK
 *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
 *                 # cigar.append((op, l))
 *                 if op == BAM_CMATCH:
 */
      __pyx_v_l = ((__pyx_v_cigar_p[__pyx_v_k]) >> 4);

      /* "pysamstats/opt.pyx":1745
 *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
 *                 # cigar.append((op, l))
 *                 if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
 *                     self.M += l
 *                 elif op == BAM_CINS:
 */
      switch (__pyx_v_op) {
        case 0:

        /* "pysamstats/opt.pyx":1746
 *                 # cigar.append((op, l))
 *                 if op == BAM_CMATCH:
 *                     self.M += l             # <<<<<<<<<<<<<<
 *                 elif op == BAM_CINS:
 *                     self.I += l
 */
        __pyx_v_self->M = (__pyx_v_self->M + __pyx_v_l);

        /* "pysamstats/opt.pyx":1745
 *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
 *                 # cigar.append((op, l))
 *                 if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
 *                     self.M += l
 *                 elif op == BAM_CINS:
 */
        break;

        /* "pysamstats/opt.pyx":1747
 *                 if op == BAM_CMATCH:
 *                     self.M += l
 *                 elif op == BAM_CINS:             # <<<<<<<<<<<<<<
 *                     self.I += l
 *                 elif op == BAM_CDEL:
 */
        case 1:

        /* "pysamstats/opt.pyx":1748
 *                     self.M += l
 *                 elif op == BAM_CINS:
 *                     self.I += l             # <<<<<<<<<<<<<<
 *                 elif op == BAM_CDEL:
 *                     self.D += l
 */
        __pyx_v_self->I = (__pyx_v_self->I + __pyx_v_l);

        /* "pysamstats/opt.pyx":1747
 *                 if op == BAM_CMATCH:
 *                     self.M += l
 *                 elif op == BAM_CINS:             # <<<<<<<<<<<<<<
 *                     self.I += l
 *                 elif op == BAM_CDEL:
 */
        break;

        /* "pysamstats/opt.pyx":1749
 *                 elif op == BAM_CINS:
 *                     self.I += l
 *                 elif op == BAM_CDEL:             # <<<<<<<<<<<<<<
 *                     self.D += l
 *                 elif op == BAM_CREF_SKIP:
 */
        case 2:

        /* "pysamstats/opt.pyx":1750
 *                     self.I += l
 *                 elif op == BAM_CDEL:
 *                     self.D += l             # <<<<<<<<<<<<<<
 *                 elif op == BAM_CREF_SKIP:
 *                     self.N += l
 */
        __pyx_v_self->D = (__pyx_v_self->D + __pyx_v_l);

        /* "pysamstats/opt.pyx":1749
 *                 elif op == BAM_CINS:
 *                     self.I += l
 *                 elif op == BAM_CDEL:             # <<<<<<<<<<<<<<
 *                     self.D += l
 *                 elif op == BAM_CREF_SKIP:
 */
        break;

        /* "pysamstats/opt.pyx":1751
 *                 elif op == BAM_CDEL:
 *                     self.D += l
 *                 elif op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
 *                     self.N += l
 *                 elif op == BAM_CSOFT_CLIP:
 */
        case 3:

        /* "pysamstats/opt.pyx":1752
 *                     self.D += l
 *                 elif op == BAM_CREF_SKIP:
 *                     self.N += l             # <<<<<<<<<<<<<<
 *                 elif op == BAM_CSOFT_CLIP:
 *                     self.S += l
 */
        __pyx_v_self->N = (__pyx_v_self->N + __pyx_v_l);

        /* "pysamstats/opt.pyx":1751
 *                 elif op == BAM_CDEL:
 *                     self.D += l
 *                 elif op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
 *                     self.N += l
 *                 elif op == BAM_CSOFT_CLIP:
 */
        break;

        /* "pysamstats/opt.pyx":1753
 *                 elif op == BAM_CREF_SKIP:
 *                     self.N += l
 *                 elif op == BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
 *                     self.S += l
 *                 elif op == BAM_CHARD_CLIP:
 */
        case 4:

        /* "pysamstats/opt.pyx":1754
 *                     self.N += l
 *                 elif op == BAM_CSOFT_CLIP:
 *                     self.S += l             # <<<<<<<<<<<<<<
 *                 elif op == BAM_CHARD_CLIP:
 *                     self.H += l
 */
        __pyx_v_self->S = (__pyx_v_self->S + __pyx_v_l);

        /* "pysamstats/opt.pyx":1753
 *                 elif op == BAM_CREF_SKIP:
 *                     self.N += l
 *                 elif op == BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
 *                     self.S += l
 *                 elif op == BAM_CHARD_CLIP:
 */
        break;

        /* "pysamstats/opt.pyx":1755
 *                 elif op == BAM_CSOFT_CLIP:
 *                     self.S += l
 *                 elif op == BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
 *                     self.H += l
 *                 elif op == BAM_CPAD:
 */
        case 5:

        /* "pysamstats/opt.pyx":1756
 *                     self.S += l
 *                 elif op == BAM_CHARD_CLIP:
 *                     self.H += l             # <<<<<<<<<<<<<<
 *                 elif op == BAM_CPAD:
 *                     self.P += l
 */
        __pyx_v_self->H = (__pyx_v_self->H + __pyx_v_l);

        /* "pysamstats/opt.pyx":1755
 *                 elif op == BAM_CSOFT_CLIP:
 *                     self.S += l
 *                 elif op == BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
 *                     self.H += l
 *                 elif op == BAM_CPAD:
 */
        break;

        /* "pysamstats/opt.pyx":1757
 *                 elif op == BAM_CHARD_CLIP:
 *                     self.H += l
 *                 elif op == BAM_CPAD:             # <<<<<<<<<<<<<<
 *                     self.P += l
 *                 elif op == BAM_CEQUAL:
 */
        case 6:

        /* "pysamstats/opt.pyx":1758
 *                     self.H += l
 *                 elif op == BAM_CPAD:
 *                     self.P += l             # <<<<<<<<<<<<<<
 *                 elif op == BAM_CEQUAL:
 *                     self.EQ += l
 */
        __pyx_v_self->P = (__pyx_v_self->P + __pyx_v_l);

        /* "pysamstats/opt.pyx":1757
 *                 elif op == BAM_CHARD_CLIP:
 *                     self.H += l
 *                 elif op == BAM_CPAD:             # <<<<<<<<<<<<<<
 *                     self.P += l
 *                 elif op == BAM_CEQUAL:
 */
        break;

        /* "pysamstats/opt.pyx":1759
 *                 elif op == BAM_CPAD:
 *                     self.P += l
 *                 elif op == BAM_CEQUAL:             # <<<<<<<<<<<<<<
 *                     self.EQ += l
 *                 elif op == BAM_CDIFF:
 */
        case 7:

        /* "pysamstats/opt.pyx":1760
 *                     self.P += l
 *                 elif op == BAM_CEQUAL:
 *                     self.EQ += l             # <<<<<<<<<<<<<<
 *                 elif op == BAM_CDIFF:
 *                     self.X += l
 */
        __pyx_v_self->EQ = (__pyx_v_self->EQ + __pyx_v_l);

        /* "pysamstats/opt.pyx":1759
 *                 elif op == BAM_CPAD:
 *                     self.P += l
 *                 elif op == BAM_CEQUAL:             # <<<<<<<<<<<<<<
 *                     self.EQ += l
 *                 elif op == BAM_CDIFF:
 */
        break;

        /* "pysamstats/opt.pyx":1761
 *                 elif op == BAM_CEQUAL:
 *                     self.EQ += l
 *                 elif op == BAM_CDIFF:             # <<<<<<<<<<<<<<
 *                     self.X += l
 *             self.reads_all += 1
 */
        case 8:

        /* "pysamstats/opt.pyx":1762
 *                     self.EQ += l
 *                 elif op == BAM_CDIFF:
 *                     self.X += l             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 * 
 */
        __pyx_v_self->X = (__pyx_v_self->X + __pyx_v_l);

        /* "pysamstats/opt.pyx":1761
 *                 elif op == BAM_CEQUAL:
 *                     self.EQ += l
 *                 elif op == BAM_CDIFF:             # <<<<<<<<<<<<<<
 *                     self.X += l
 *             self.reads_all += 1
 */
        break;
        default: break;
      }
    }

    /* "pysamstats/opt.pyx":1763
 *                 elif op == BAM_CDIFF:
 *                     self.X += l
 *             self.reads_all += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_self->reads_all = (__pyx_v_self->reads_all + 1);

    /* "pysamstats/opt.pyx":1738
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             cigar_p = pysam_bam_get_cigar(b)
 *             # cigar = list()
 */
  }

  /* "pysamstats/opt.pyx":1732
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

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

/* "pysamstats/opt.pyx":1780
 *     cdef int64_t tlen_pp_squared_sum
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.tlen_sum = self.tlen_squared_sum = self.tlen_pp_sum = \
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0
 */

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

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

static int __pyx_pf_10pysamstats_3opt_10TlenBinned___init__(struct __pyx_obj_10pysamstats_3opt_TlenBinned *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "pysamstats/opt.pyx":1781
 * 
 *     def __init__(self):
 *         self.tlen_sum = self.tlen_squared_sum = self.tlen_pp_sum = \             # <<<<<<<<<<<<<<
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0
 * 
 */
  __pyx_v_self->tlen_sum = 0;
  __pyx_v_self->tlen_squared_sum = 0;
  __pyx_v_self->tlen_pp_sum = 0;

  /* "pysamstats/opt.pyx":1782
 *     def __init__(self):
 *         self.tlen_sum = self.tlen_squared_sum = self.tlen_pp_sum = \
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0             # <<<<<<<<<<<<<<
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):
 */
  __pyx_v_self->tlen_pp_squared_sum = 0;
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->reads_pp = 0;

  /* "pysamstats/opt.pyx":1780
 *     cdef int64_t tlen_pp_squared_sum
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.tlen_sum = self.tlen_squared_sum = self.tlen_pp_sum = \
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0
 */

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

/* "pysamstats/opt.pyx":1784
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # make record for bin
 */

static PyObject *__pyx_f_10pysamstats_3opt_10TlenBinned_rec(struct __pyx_obj_10pysamstats_3opt_TlenBinned *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_chrom, CYTHON_UNUSED PyObject *__pyx_v_bin_start, CYTHON_UNUSED PyObject *__pyx_v_bin_end, CYTHON_UNUSED struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile) {
  PyObject *__pyx_v_rec = 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;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("rec", 0);

  /* "pysamstats/opt.pyx":1787
 * 
 *         # make record for bin
 *         rec = {'reads_all': self.reads_all, 'reads_pp': self.reads_pp,             # <<<<<<<<<<<<<<
 *                'mean_tlen': mean(self.tlen_sum, self.reads_all),
 *                'mean_tlen_pp': mean(self.tlen_pp_sum, self.reads_pp),
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_all, __pyx_t_2) < 0) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->reads_pp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reads_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1788
 *         # make record for bin
 *         rec = {'reads_all': self.reads_all, 'reads_pp': self.reads_pp,
 *                'mean_tlen': mean(self.tlen_sum, self.reads_all),             # <<<<<<<<<<<<<<
 *                'mean_tlen_pp': mean(self.tlen_pp_sum, self.reads_pp),
 *                'rms_tlen': rootmean(self.tlen_squared_sum, self.reads_all),
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int64_t(__pyx_v_self->tlen_sum); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen, __pyx_t_2) < 0) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1789
 *         rec = {'reads_all': self.reads_all, 'reads_pp': self.reads_pp,
 *                'mean_tlen': mean(self.tlen_sum, self.reads_all),
 *                'mean_tlen_pp': mean(self.tlen_pp_sum, self.reads_pp),             # <<<<<<<<<<<<<<
 *                'rms_tlen': rootmean(self.tlen_squared_sum, self.reads_all),
 *                'rms_tlen_pp': rootmean(self.tlen_pp_squared_sum,
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyInt_From_int64_t(__pyx_v_self->tlen_pp_sum); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->reads_pp); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1789, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_8, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1789, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_8, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1789, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1789, __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_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_5);
    __pyx_t_8 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1789, __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;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mean_tlen_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1790
 *                'mean_tlen': mean(self.tlen_sum, self.reads_all),
 *                'mean_tlen_pp': mean(self.tlen_pp_sum, self.reads_pp),
 *                'rms_tlen': rootmean(self.tlen_squared_sum, self.reads_all),             # <<<<<<<<<<<<<<
 *                'rms_tlen_pp': rootmean(self.tlen_pp_squared_sum,
 *                                        self.reads_pp)}
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_rootmean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyInt_From_int64_t(__pyx_v_self->tlen_squared_sum); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->reads_all); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && 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_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1790, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_6, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1790, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_t_5);
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1790, __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;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen, __pyx_t_2) < 0) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1791
 *                'mean_tlen_pp': mean(self.tlen_pp_sum, self.reads_pp),
 *                'rms_tlen': rootmean(self.tlen_squared_sum, self.reads_all),
 *                'rms_tlen_pp': rootmean(self.tlen_pp_squared_sum,             # <<<<<<<<<<<<<<
 *                                        self.reads_pp)}
 * 
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_rootmean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int64_t(__pyx_v_self->tlen_pp_squared_sum); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "pysamstats/opt.pyx":1792
 *                'rms_tlen': rootmean(self.tlen_squared_sum, self.reads_all),
 *                'rms_tlen_pp': rootmean(self.tlen_pp_squared_sum,
 *                                        self.reads_pp)}             # <<<<<<<<<<<<<<
 * 
 *         # reset counters
 */
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->reads_pp); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_7 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1791, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1791, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_rms_tlen_pp, __pyx_t_2) < 0) __PYX_ERR(0, 1787, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1795
 * 
 *         # reset counters
 *         self.tlen_sum = self.tlen_squared_sum = self.tlen_pp_sum = \             # <<<<<<<<<<<<<<
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0
 * 
 */
  __pyx_v_self->tlen_sum = 0;
  __pyx_v_self->tlen_squared_sum = 0;
  __pyx_v_self->tlen_pp_sum = 0;

  /* "pysamstats/opt.pyx":1796
 *         # reset counters
 *         self.tlen_sum = self.tlen_squared_sum = self.tlen_pp_sum = \
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0             # <<<<<<<<<<<<<<
 * 
 *         return rec
 */
  __pyx_v_self->tlen_pp_squared_sum = 0;
  __pyx_v_self->reads_all = 0;
  __pyx_v_self->reads_pp = 0;

  /* "pysamstats/opt.pyx":1798
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0
 * 
 *         return rec             # <<<<<<<<<<<<<<
 * 
 *     cdef void recv(self, bam1_t* b):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1784
 *             self.tlen_pp_squared_sum = self.reads_all = self.reads_pp = 0
 * 
 *     cdef dict rec(self, chrom, bin_start, bin_end, FastaFile fafile):             # <<<<<<<<<<<<<<
 * 
 *         # make record for bin
 */

  /* 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_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("pysamstats.opt.TlenBinned.rec", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1800
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

static void __pyx_f_10pysamstats_3opt_10TlenBinned_recv(struct __pyx_obj_10pysamstats_3opt_TlenBinned *__pyx_v_self, bam1_t *__pyx_v_b) {
  uint32_t __pyx_v_flag;
  int __pyx_v_is_unmapped;
  int __pyx_v_is_proper_pair;
  int64_t __pyx_v_tlen;
  int64_t __pyx_v_tlen_squared;
  __Pyx_RefNannyDeclarations
  uint16_t __pyx_t_1;
  int __pyx_t_2;
  int32_t __pyx_t_3;
  __Pyx_RefNannySetupContext("recv", 0);

  /* "pysamstats/opt.pyx":1806
 *         cdef int64_t tlen
 *         cdef int64_t tlen_squared
 *         flag = b.core.flag             # <<<<<<<<<<<<<<
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 */
  __pyx_t_1 = __pyx_v_b->core.flag;
  __pyx_v_flag = __pyx_t_1;

  /* "pysamstats/opt.pyx":1807
 *         cdef int64_t tlen_squared
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)             # <<<<<<<<<<<<<<
 *         if not is_unmapped:
 *             self.reads_all += 1
 */
  __pyx_v_is_unmapped = ((__pyx_v_flag & 4) != 0);

  /* "pysamstats/opt.pyx":1808
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 *             tlen = b.core.isize
 */
  __pyx_t_2 = ((!(__pyx_v_is_unmapped != 0)) != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1809
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:
 *             self.reads_all += 1             # <<<<<<<<<<<<<<
 *             tlen = b.core.isize
 *             self.tlen_sum += tlen
 */
    __pyx_v_self->reads_all = (__pyx_v_self->reads_all + 1);

    /* "pysamstats/opt.pyx":1810
 *         if not is_unmapped:
 *             self.reads_all += 1
 *             tlen = b.core.isize             # <<<<<<<<<<<<<<
 *             self.tlen_sum += tlen
 *             tlen_squared = tlen**2
 */
    __pyx_t_3 = __pyx_v_b->core.isize;
    __pyx_v_tlen = __pyx_t_3;

    /* "pysamstats/opt.pyx":1811
 *             self.reads_all += 1
 *             tlen = b.core.isize
 *             self.tlen_sum += tlen             # <<<<<<<<<<<<<<
 *             tlen_squared = tlen**2
 *             self.tlen_squared_sum += tlen_squared
 */
    __pyx_v_self->tlen_sum = (__pyx_v_self->tlen_sum + __pyx_v_tlen);

    /* "pysamstats/opt.pyx":1812
 *             tlen = b.core.isize
 *             self.tlen_sum += tlen
 *             tlen_squared = tlen**2             # <<<<<<<<<<<<<<
 *             self.tlen_squared_sum += tlen_squared
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 */
    __pyx_v_tlen_squared = __Pyx_pow_int64_t(__pyx_v_tlen, 2);

    /* "pysamstats/opt.pyx":1813
 *             self.tlen_sum += tlen
 *             tlen_squared = tlen**2
 *             self.tlen_squared_sum += tlen_squared             # <<<<<<<<<<<<<<
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             if is_proper_pair:
 */
    __pyx_v_self->tlen_squared_sum = (__pyx_v_self->tlen_squared_sum + __pyx_v_tlen_squared);

    /* "pysamstats/opt.pyx":1814
 *             tlen_squared = tlen**2
 *             self.tlen_squared_sum += tlen_squared
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)             # <<<<<<<<<<<<<<
 *             if is_proper_pair:
 *                 self.reads_pp += 1
 */
    __pyx_v_is_proper_pair = ((__pyx_v_flag & 2) != 0);

    /* "pysamstats/opt.pyx":1815
 *             self.tlen_squared_sum += tlen_squared
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.reads_pp += 1
 *                 self.tlen_pp_sum += tlen
 */
    __pyx_t_2 = (__pyx_v_is_proper_pair != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":1816
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             if is_proper_pair:
 *                 self.reads_pp += 1             # <<<<<<<<<<<<<<
 *                 self.tlen_pp_sum += tlen
 *                 self.tlen_pp_squared_sum += tlen_squared
 */
      __pyx_v_self->reads_pp = (__pyx_v_self->reads_pp + 1);

      /* "pysamstats/opt.pyx":1817
 *             if is_proper_pair:
 *                 self.reads_pp += 1
 *                 self.tlen_pp_sum += tlen             # <<<<<<<<<<<<<<
 *                 self.tlen_pp_squared_sum += tlen_squared
 * 
 */
      __pyx_v_self->tlen_pp_sum = (__pyx_v_self->tlen_pp_sum + __pyx_v_tlen);

      /* "pysamstats/opt.pyx":1818
 *                 self.reads_pp += 1
 *                 self.tlen_pp_sum += tlen
 *                 self.tlen_pp_squared_sum += tlen_squared             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_v_self->tlen_pp_squared_sum = (__pyx_v_self->tlen_pp_squared_sum + __pyx_v_tlen_squared);

      /* "pysamstats/opt.pyx":1815
 *             self.tlen_squared_sum += tlen_squared
 *             is_proper_pair = <bint>(flag & BAM_FPROPER_PAIR)
 *             if is_proper_pair:             # <<<<<<<<<<<<<<
 *                 self.reads_pp += 1
 *                 self.tlen_pp_sum += tlen
 */
    }

    /* "pysamstats/opt.pyx":1808
 *         flag = b.core.flag
 *         is_unmapped = <bint>(flag & BAM_FUNMAP)
 *         if not is_unmapped:             # <<<<<<<<<<<<<<
 *             self.reads_all += 1
 *             tlen = b.core.isize
 */
  }

  /* "pysamstats/opt.pyx":1800
 *         return rec
 * 
 *     cdef void recv(self, bam1_t* b):             # <<<<<<<<<<<<<<
 *         cdef uint32_t flag
 *         cdef bint is_unmapped
 */

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

/* "pysamstats/opt.pyx":1826
 * 
 * 
 * def iter_pileup(stat, alignmentfile, fafile, pad, **kwargs):             # <<<<<<<<<<<<<<
 *     """General purpose function to generate statistics, where one record is
 *     generated for each genome position in the selected range, based on a
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_1iter_pileup(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_iter_pileup[] = "iter_pileup(stat, alignmentfile, fafile, pad, **kwargs)\nGeneral purpose function to generate statistics, where one record is\n    generated for each genome position in the selected range, based on a\n    pileup column.\n\n    ";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_1iter_pileup = {"iter_pileup", (PyCFunction)__pyx_pw_10pysamstats_3opt_1iter_pileup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_iter_pileup};
static PyObject *__pyx_pw_10pysamstats_3opt_1iter_pileup(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stat = 0;
  PyObject *__pyx_v_alignmentfile = 0;
  PyObject *__pyx_v_fafile = 0;
  PyObject *__pyx_v_pad = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_pileup (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stat,&__pyx_n_s_alignmentfile,&__pyx_n_s_fafile,&__pyx_n_s_pad,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_stat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alignmentfile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup", 1, 4, 4, 1); __PYX_ERR(0, 1826, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fafile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup", 1, 4, 4, 2); __PYX_ERR(0, 1826, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pad)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup", 1, 4, 4, 3); __PYX_ERR(0, 1826, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "iter_pileup") < 0)) __PYX_ERR(0, 1826, __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_stat = values[0];
    __pyx_v_alignmentfile = values[1];
    __pyx_v_fafile = values[2];
    __pyx_v_pad = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iter_pileup", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1826, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysamstats.opt.iter_pileup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10pysamstats_3opt_iter_pileup(__pyx_self, __pyx_v_stat, __pyx_v_alignmentfile, __pyx_v_fafile, __pyx_v_pad, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_10pysamstats_3opt_iter_pileup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_pad, PyObject *__pyx_v_kwargs) {
  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;
  __Pyx_RefNannySetupContext("iter_pileup", 0);
  __Pyx_INCREF(__pyx_v_alignmentfile);
  __Pyx_INCREF(__pyx_v_fafile);

  /* "pysamstats/opt.pyx":1833
 *     """
 * 
 *     if isinstance(alignmentfile, _string_types):             # <<<<<<<<<<<<<<
 *         alignmentfile = AlignmentFile(alignmentfile)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1833, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_alignmentfile, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 1833, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":1834
 * 
 *     if isinstance(alignmentfile, _string_types):
 *         alignmentfile = AlignmentFile(alignmentfile)             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(fafile, _string_types):
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_alignmentfile);
    __Pyx_GIVEREF(__pyx_v_alignmentfile);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_alignmentfile);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1834, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_alignmentfile, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysamstats/opt.pyx":1833
 *     """
 * 
 *     if isinstance(alignmentfile, _string_types):             # <<<<<<<<<<<<<<
 *         alignmentfile = AlignmentFile(alignmentfile)
 * 
 */
  }

  /* "pysamstats/opt.pyx":1836
 *         alignmentfile = AlignmentFile(alignmentfile)
 * 
 *     if isinstance(fafile, _string_types):             # <<<<<<<<<<<<<<
 *         fafile = FastaFile(fafile)
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_string_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_fafile, __pyx_t_4); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 1836, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1837
 * 
 *     if isinstance(fafile, _string_types):
 *         fafile = FastaFile(fafile)             # <<<<<<<<<<<<<<
 * 
 *     if pad:
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_fafile);
    __Pyx_GIVEREF(__pyx_v_fafile);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fafile);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5pysam_9libcfaidx_FastaFile), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_fafile, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pysamstats/opt.pyx":1836
 *         alignmentfile = AlignmentFile(alignmentfile)
 * 
 *     if isinstance(fafile, _string_types):             # <<<<<<<<<<<<<<
 *         fafile = FastaFile(fafile)
 * 
 */
  }

  /* "pysamstats/opt.pyx":1839
 *         fafile = FastaFile(fafile)
 * 
 *     if pad:             # <<<<<<<<<<<<<<
 *         return iter_pileup_padded(stat, alignmentfile=alignmentfile, fafile=fafile, **kwargs)
 *     else:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_pad); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1839, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1840
 * 
 *     if pad:
 *         return iter_pileup_padded(stat, alignmentfile=alignmentfile, fafile=fafile, **kwargs)             # <<<<<<<<<<<<<<
 *     else:
 *         return iter_pileup_default(stat, alignmentfile=alignmentfile, fafile=fafile, **kwargs)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_iter_pileup_padded); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_stat);
    __Pyx_GIVEREF(__pyx_v_stat);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stat);
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_alignmentfile, __pyx_v_alignmentfile) < 0) __PYX_ERR(0, 1840, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_fafile, __pyx_v_fafile) < 0) __PYX_ERR(0, 1840, __pyx_L1_error)
    __pyx_t_5 = __pyx_t_6;
    __pyx_t_6 = 0;
    if (__Pyx_MergeKeywords(__pyx_t_5, __pyx_v_kwargs) < 0) __PYX_ERR(0, 1840, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "pysamstats/opt.pyx":1839
 *         fafile = FastaFile(fafile)
 * 
 *     if pad:             # <<<<<<<<<<<<<<
 *         return iter_pileup_padded(stat, alignmentfile=alignmentfile, fafile=fafile, **kwargs)
 *     else:
 */
  }

  /* "pysamstats/opt.pyx":1842
 *         return iter_pileup_padded(stat, alignmentfile=alignmentfile, fafile=fafile, **kwargs)
 *     else:
 *         return iter_pileup_default(stat, alignmentfile=alignmentfile, fafile=fafile, **kwargs)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_iter_pileup_default); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1842, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1842, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_stat);
    __Pyx_GIVEREF(__pyx_v_stat);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_stat);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1842, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_alignmentfile, __pyx_v_alignmentfile) < 0) __PYX_ERR(0, 1842, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_fafile, __pyx_v_fafile) < 0) __PYX_ERR(0, 1842, __pyx_L1_error)
    __pyx_t_4 = __pyx_t_1;
    __pyx_t_1 = 0;
    if (__Pyx_MergeKeywords(__pyx_t_4, __pyx_v_kwargs) < 0) __PYX_ERR(0, 1842, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1842, __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;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "pysamstats/opt.pyx":1826
 * 
 * 
 * def iter_pileup(stat, alignmentfile, fafile, pad, **kwargs):             # <<<<<<<<<<<<<<
 *     """General purpose function to generate statistics, where one record is
 *     generated for each genome position in the selected range, based on a
 */

  /* 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("pysamstats.opt.iter_pileup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_alignmentfile);
  __Pyx_XDECREF(__pyx_v_fafile);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10pysamstats_3opt_4generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "pysamstats/opt.pyx":1845
 * 
 * 
 * def iter_pileup_default(stat, alignmentfile, fafile, chrom, start, end, one_based, truncate,             # <<<<<<<<<<<<<<
 *                         max_depth, int min_mapq, int min_baseq, bint no_del, bint no_dup):
 *     cdef:
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_3iter_pileup_default(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_2iter_pileup_default[] = "iter_pileup_default(stat, alignmentfile, fafile, chrom, start, end, one_based, truncate, max_depth, int min_mapq, int min_baseq, bool no_del, bool no_dup)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_3iter_pileup_default = {"iter_pileup_default", (PyCFunction)__pyx_pw_10pysamstats_3opt_3iter_pileup_default, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_2iter_pileup_default};
static PyObject *__pyx_pw_10pysamstats_3opt_3iter_pileup_default(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stat = 0;
  PyObject *__pyx_v_alignmentfile = 0;
  PyObject *__pyx_v_fafile = 0;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_end = 0;
  PyObject *__pyx_v_one_based = 0;
  PyObject *__pyx_v_truncate = 0;
  PyObject *__pyx_v_max_depth = 0;
  int __pyx_v_min_mapq;
  int __pyx_v_min_baseq;
  int __pyx_v_no_del;
  int __pyx_v_no_dup;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_pileup_default (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stat,&__pyx_n_s_alignmentfile,&__pyx_n_s_fafile,&__pyx_n_s_chrom,&__pyx_n_s_start,&__pyx_n_s_end,&__pyx_n_s_one_based,&__pyx_n_s_truncate,&__pyx_n_s_max_depth,&__pyx_n_s_min_mapq,&__pyx_n_s_min_baseq,&__pyx_n_s_no_del,&__pyx_n_s_no_dup,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,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 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alignmentfile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 1); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fafile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 2); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chrom)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 3); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 4); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 5); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_one_based)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 6); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_truncate)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 7); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_max_depth)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 8); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case  9:
        if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_mapq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 9); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case 10:
        if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_baseq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 10); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case 11:
        if (likely((values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_no_del)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 11); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
        case 12:
        if (likely((values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_no_dup)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, 12); __PYX_ERR(0, 1845, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iter_pileup_default") < 0)) __PYX_ERR(0, 1845, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 13) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
    }
    __pyx_v_stat = values[0];
    __pyx_v_alignmentfile = values[1];
    __pyx_v_fafile = values[2];
    __pyx_v_chrom = values[3];
    __pyx_v_start = values[4];
    __pyx_v_end = values[5];
    __pyx_v_one_based = values[6];
    __pyx_v_truncate = values[7];
    __pyx_v_max_depth = values[8];
    __pyx_v_min_mapq = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_min_mapq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1846, __pyx_L3_error)
    __pyx_v_min_baseq = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_min_baseq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1846, __pyx_L3_error)
    __pyx_v_no_del = __Pyx_PyObject_IsTrue(values[11]); if (unlikely((__pyx_v_no_del == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1846, __pyx_L3_error)
    __pyx_v_no_dup = __Pyx_PyObject_IsTrue(values[12]); if (unlikely((__pyx_v_no_dup == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1846, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iter_pileup_default", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1845, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.iter_pileup_default", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10pysamstats_3opt_2iter_pileup_default(__pyx_self, __pyx_v_stat, __pyx_v_alignmentfile, __pyx_v_fafile, __pyx_v_chrom, __pyx_v_start, __pyx_v_end, __pyx_v_one_based, __pyx_v_truncate, __pyx_v_max_depth, __pyx_v_min_mapq, __pyx_v_min_baseq, __pyx_v_no_del, __pyx_v_no_dup);

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

static PyObject *__pyx_pf_10pysamstats_3opt_2iter_pileup_default(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_one_based, PyObject *__pyx_v_truncate, PyObject *__pyx_v_max_depth, int __pyx_v_min_mapq, int __pyx_v_min_baseq, int __pyx_v_no_del, int __pyx_v_no_dup) {
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_pileup_default", 0);
  __pyx_cur_scope = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *)__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default(__pyx_ptype_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1845, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_stat = __pyx_v_stat;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stat);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stat);
  __pyx_cur_scope->__pyx_v_alignmentfile = __pyx_v_alignmentfile;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_alignmentfile);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_alignmentfile);
  __pyx_cur_scope->__pyx_v_fafile = __pyx_v_fafile;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fafile);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fafile);
  __pyx_cur_scope->__pyx_v_chrom = __pyx_v_chrom;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
  __pyx_cur_scope->__pyx_v_start = __pyx_v_start;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
  __pyx_cur_scope->__pyx_v_end = __pyx_v_end;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end);
  __pyx_cur_scope->__pyx_v_one_based = __pyx_v_one_based;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_one_based);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_one_based);
  __pyx_cur_scope->__pyx_v_truncate = __pyx_v_truncate;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_truncate);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_truncate);
  __pyx_cur_scope->__pyx_v_max_depth = __pyx_v_max_depth;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_max_depth);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_max_depth);
  __pyx_cur_scope->__pyx_v_min_mapq = __pyx_v_min_mapq;
  __pyx_cur_scope->__pyx_v_min_baseq = __pyx_v_min_baseq;
  __pyx_cur_scope->__pyx_v_no_del = __pyx_v_no_del;
  __pyx_cur_scope->__pyx_v_no_dup = __pyx_v_no_dup;
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10pysamstats_3opt_4generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter_pileup_default, __pyx_n_s_iter_pileup_default, __pyx_n_s_pysamstats_opt); if (unlikely(!gen)) __PYX_ERR(0, 1845, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysamstats.opt.iter_pileup_default", __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_10pysamstats_3opt_4generator(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *__pyx_cur_scope = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1845, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1851
 * 
 *     # obtain pileup iterator
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)             # <<<<<<<<<<<<<<
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,
 *                               max_depth=max_depth)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_normalise_coords); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_alignmentfile, __pyx_cur_scope->__pyx_v_chrom, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_end, __pyx_cur_scope->__pyx_v_one_based};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 5+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1851, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[6] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_alignmentfile, __pyx_cur_scope->__pyx_v_chrom, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_end, __pyx_cur_scope->__pyx_v_one_based};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 5+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1851, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(5+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1851, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_alignmentfile);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_alignmentfile);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_cur_scope->__pyx_v_alignmentfile);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_cur_scope->__pyx_v_chrom);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_cur_scope->__pyx_v_start);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_cur_scope->__pyx_v_end);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_one_based);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_one_based);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_cur_scope->__pyx_v_one_based);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1851, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if !CYTHON_COMPILING_IN_PYPY
    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_ERR(0, 1851, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1851, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1851, __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_ERR(0, 1851, __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_2 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_5)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) __PYX_ERR(0, 1851, __pyx_L1_error)
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1851, __pyx_L1_error)
    __pyx_L5_unpacking_done:;
  }
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_end);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_end, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;

  /* "pysamstats/opt.pyx":1852
 *     # obtain pileup iterator
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,             # <<<<<<<<<<<<<<
 *                               max_depth=max_depth)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_alignmentfile, __pyx_n_s_pileup); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reference, __pyx_cur_scope->__pyx_v_chrom) < 0) __PYX_ERR(0, 1852, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_start, __pyx_cur_scope->__pyx_v_start) < 0) __PYX_ERR(0, 1852, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_end, __pyx_cur_scope->__pyx_v_end) < 0) __PYX_ERR(0, 1852, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_truncate, __pyx_cur_scope->__pyx_v_truncate) < 0) __PYX_ERR(0, 1852, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1853
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,
 *                               max_depth=max_depth)             # <<<<<<<<<<<<<<
 * 
 *     # iterate over pileup columns
 */
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_max_depth, __pyx_cur_scope->__pyx_v_max_depth) < 0) __PYX_ERR(0, 1852, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1852
 *     # obtain pileup iterator
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,             # <<<<<<<<<<<<<<
 *                               max_depth=max_depth)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1852, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_it = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1856
 * 
 *     # iterate over pileup columns
 *     for col in it:             # <<<<<<<<<<<<<<
 * 
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,
 */
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_it)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_it)) {
    __pyx_t_2 = __pyx_cur_scope->__pyx_v_it; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_it); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1856, __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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 1856, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1856, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 1856, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1856, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_8(__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_ERR(0, 1856, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5pysam_18libcalignedsegment_PileupColumn))))) __PYX_ERR(0, 1856, __pyx_L1_error)
    __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_col));
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_col, ((struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *)__pyx_t_5));
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;

    /* "pysamstats/opt.pyx":1858
 *     for col in it:
 * 
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,
 *                           no_del=no_del, no_dup=no_dup)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stat_pileup); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1858, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1858, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stat);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stat);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_stat);
    __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_col));
    __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_col));
    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_cur_scope->__pyx_v_col));
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1858, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_alignmentfile, __pyx_cur_scope->__pyx_v_alignmentfile) < 0) __PYX_ERR(0, 1858, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_fafile, __pyx_cur_scope->__pyx_v_fafile) < 0) __PYX_ERR(0, 1858, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1859
 * 
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,             # <<<<<<<<<<<<<<
 *                           no_del=no_del, no_dup=no_dup)
 * 
 */
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_one_based, __pyx_cur_scope->__pyx_v_one_based) < 0) __PYX_ERR(0, 1858, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_min_mapq); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_min_mapq, __pyx_t_9) < 0) __PYX_ERR(0, 1858, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_min_baseq); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_min_baseq, __pyx_t_9) < 0) __PYX_ERR(0, 1858, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pysamstats/opt.pyx":1860
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,
 *                           no_del=no_del, no_dup=no_dup)             # <<<<<<<<<<<<<<
 * 
 *         yield rec
 */
    __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_no_del); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1860, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_no_del, __pyx_t_9) < 0) __PYX_ERR(0, 1858, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_no_dup); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1860, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_no_dup, __pyx_t_9) < 0) __PYX_ERR(0, 1858, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "pysamstats/opt.pyx":1858
 *     for col in it:
 * 
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,
 *                           no_del=no_del, no_dup=no_dup)
 */
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1858, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_rec);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_rec, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;

    /* "pysamstats/opt.pyx":1862
 *                           no_del=no_del, no_dup=no_dup)
 * 
 *         yield rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_rec);
    __pyx_r = __pyx_cur_scope->__pyx_v_rec;
    __Pyx_XGIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_2);
    __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1862, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1856
 * 
 *     # iterate over pileup columns
 *     for col in it:             # <<<<<<<<<<<<<<
 * 
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysamstats/opt.pyx":1845
 * 
 * 
 * def iter_pileup_default(stat, alignmentfile, fafile, chrom, start, end, one_based, truncate,             # <<<<<<<<<<<<<<
 *                         max_depth, int min_mapq, int min_baseq, bint no_del, bint no_dup):
 *     cdef:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  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_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("iter_pileup_default", __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;
}

/* "pysamstats/opt.pyx":1865
 * 
 * 
 * def stat_pileup(PileupStat stat,             # <<<<<<<<<<<<<<
 *                 PileupColumn col,
 *                 AlignmentFile alignmentfile,
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_6stat_pileup(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_5stat_pileup[] = "stat_pileup(PileupStat stat, PileupColumn col, AlignmentFile alignmentfile, FastaFile fafile, bool one_based, int min_mapq, int min_baseq, bool no_del, bool no_dup)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_6stat_pileup = {"stat_pileup", (PyCFunction)__pyx_pw_10pysamstats_3opt_6stat_pileup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_5stat_pileup};
static PyObject *__pyx_pw_10pysamstats_3opt_6stat_pileup(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_stat = 0;
  struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col = 0;
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile = 0;
  struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile = 0;
  int __pyx_v_one_based;
  int __pyx_v_min_mapq;
  int __pyx_v_min_baseq;
  int __pyx_v_no_del;
  int __pyx_v_no_dup;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stat_pileup (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stat,&__pyx_n_s_col,&__pyx_n_s_alignmentfile,&__pyx_n_s_fafile,&__pyx_n_s_one_based,&__pyx_n_s_min_mapq,&__pyx_n_s_min_baseq,&__pyx_n_s_no_del,&__pyx_n_s_no_dup,0};
    PyObject* values[9] = {0,0,0,0,0,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  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_col)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, 1); __PYX_ERR(0, 1865, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alignmentfile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, 2); __PYX_ERR(0, 1865, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fafile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, 3); __PYX_ERR(0, 1865, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_one_based)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, 4); __PYX_ERR(0, 1865, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_mapq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, 5); __PYX_ERR(0, 1865, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_baseq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, 6); __PYX_ERR(0, 1865, __pyx_L3_error)
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_no_del)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, 7); __PYX_ERR(0, 1865, __pyx_L3_error)
        }
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_no_dup)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, 8); __PYX_ERR(0, 1865, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "stat_pileup") < 0)) __PYX_ERR(0, 1865, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
    }
    __pyx_v_stat = ((struct __pyx_obj_10pysamstats_3opt_PileupStat *)values[0]);
    __pyx_v_col = ((struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *)values[1]);
    __pyx_v_alignmentfile = ((struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *)values[2]);
    __pyx_v_fafile = ((struct __pyx_obj_5pysam_9libcfaidx_FastaFile *)values[3]);
    __pyx_v_one_based = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_one_based == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1869, __pyx_L3_error)
    __pyx_v_min_mapq = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_min_mapq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1870, __pyx_L3_error)
    __pyx_v_min_baseq = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_min_baseq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1871, __pyx_L3_error)
    __pyx_v_no_del = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_no_del == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1872, __pyx_L3_error)
    __pyx_v_no_dup = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_no_dup == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1873, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("stat_pileup", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1865, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.stat_pileup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stat), __pyx_ptype_10pysamstats_3opt_PileupStat, 1, "stat", 0))) __PYX_ERR(0, 1865, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_col), __pyx_ptype_5pysam_18libcalignedsegment_PileupColumn, 1, "col", 0))) __PYX_ERR(0, 1866, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alignmentfile), __pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile, 1, "alignmentfile", 0))) __PYX_ERR(0, 1867, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fafile), __pyx_ptype_5pysam_9libcfaidx_FastaFile, 1, "fafile", 0))) __PYX_ERR(0, 1868, __pyx_L1_error)
  __pyx_r = __pyx_pf_10pysamstats_3opt_5stat_pileup(__pyx_self, __pyx_v_stat, __pyx_v_col, __pyx_v_alignmentfile, __pyx_v_fafile, __pyx_v_one_based, __pyx_v_min_mapq, __pyx_v_min_baseq, __pyx_v_no_del, __pyx_v_no_dup);

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

static PyObject *__pyx_pf_10pysamstats_3opt_5stat_pileup(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_stat, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *__pyx_v_col, struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, int __pyx_v_one_based, int __pyx_v_min_mapq, int __pyx_v_min_baseq, int __pyx_v_no_del, int __pyx_v_no_dup) {
  bam_pileup1_t **__pyx_v_plp;
  bam_pileup1_t *__pyx_v_read;
  bam1_t *__pyx_v_b;
  int __pyx_v_i;
  int __pyx_v_n;
  PyObject *__pyx_v_chrom = NULL;
  PyObject *__pyx_v_refbase = NULL;
  PyObject *__pyx_v_rec = NULL;
  long __pyx_v_pos;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  bam_pileup1_t **__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_t_8;
  bam1_t *__pyx_t_9;
  int __pyx_t_10;
  long __pyx_t_11;
  __Pyx_RefNannySetupContext("stat_pileup", 0);

  /* "pysamstats/opt.pyx":1881
 * 
 *     # setup intermediate variables
 *     n = col.n             # <<<<<<<<<<<<<<
 *     plp = col.plp
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_col), __pyx_n_s_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1881, __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_ERR(0, 1881, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_n = __pyx_t_2;

  /* "pysamstats/opt.pyx":1882
 *     # setup intermediate variables
 *     n = col.n
 *     plp = col.plp             # <<<<<<<<<<<<<<
 * 
 *     # get current chromosome
 */
  __pyx_t_3 = __pyx_v_col->plp;
  __pyx_v_plp = __pyx_t_3;

  /* "pysamstats/opt.pyx":1885
 * 
 *     # get current chromosome
 *     chrom = alignmentfile.getrname(col.tid)             # <<<<<<<<<<<<<<
 * 
 *     # setup reference base
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_alignmentfile), __pyx_n_s_getrname); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_col->tid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1885, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1885, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1885, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1885, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1885, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1885, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_chrom = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1888
 * 
 *     # setup reference base
 *     refbase = get_refbase(fafile, chrom, col.pos)             # <<<<<<<<<<<<<<
 * 
 *     # iterate over reads in the column
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_refbase); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_col->pos); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1888, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_5 = NULL;
  __pyx_t_2 = 0;
  if (CYTHON_UNPACK_METHODS && 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_2 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_fafile), __pyx_v_chrom, __pyx_t_7};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_2, 3+__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1888, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_fafile), __pyx_v_chrom, __pyx_t_7};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_2, 3+__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1888, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(3+__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1888, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_fafile));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_fafile));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_2, ((PyObject *)__pyx_v_fafile));
    __Pyx_INCREF(__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_2, __pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_2, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1888, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_refbase = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":1891
 * 
 *     # iterate over reads in the column
 *     for i in range(n):             # <<<<<<<<<<<<<<
 *         read = &(plp[0][i])
 *         b = read.b
 */
  __pyx_t_2 = __pyx_v_n;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_2; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "pysamstats/opt.pyx":1892
 *     # iterate over reads in the column
 *     for i in range(n):
 *         read = &(plp[0][i])             # <<<<<<<<<<<<<<
 *         b = read.b
 * 
 */
    __pyx_v_read = (&((__pyx_v_plp[0])[__pyx_v_i]));

    /* "pysamstats/opt.pyx":1893
 *     for i in range(n):
 *         read = &(plp[0][i])
 *         b = read.b             # <<<<<<<<<<<<<<
 * 
 *         # read filters
 */
    __pyx_t_9 = __pyx_v_read->b;
    __pyx_v_b = __pyx_t_9;

    /* "pysamstats/opt.pyx":1896
 * 
 *         # read filters
 *         if min_mapq > 0:             # <<<<<<<<<<<<<<
 *             if b.core.qual < min_mapq:
 *                 continue
 */
    __pyx_t_10 = ((__pyx_v_min_mapq > 0) != 0);
    if (__pyx_t_10) {

      /* "pysamstats/opt.pyx":1897
 *         # read filters
 *         if min_mapq > 0:
 *             if b.core.qual < min_mapq:             # <<<<<<<<<<<<<<
 *                 continue
 *         if min_baseq > 0:
 */
      __pyx_t_10 = ((__pyx_v_b->core.qual < __pyx_v_min_mapq) != 0);
      if (__pyx_t_10) {

        /* "pysamstats/opt.pyx":1898
 *         if min_mapq > 0:
 *             if b.core.qual < min_mapq:
 *                 continue             # <<<<<<<<<<<<<<
 *         if min_baseq > 0:
 *             if not read.is_del:
 */
        goto __pyx_L3_continue;

        /* "pysamstats/opt.pyx":1897
 *         # read filters
 *         if min_mapq > 0:
 *             if b.core.qual < min_mapq:             # <<<<<<<<<<<<<<
 *                 continue
 *         if min_baseq > 0:
 */
      }

      /* "pysamstats/opt.pyx":1896
 * 
 *         # read filters
 *         if min_mapq > 0:             # <<<<<<<<<<<<<<
 *             if b.core.qual < min_mapq:
 *                 continue
 */
    }

    /* "pysamstats/opt.pyx":1899
 *             if b.core.qual < min_mapq:
 *                 continue
 *         if min_baseq > 0:             # <<<<<<<<<<<<<<
 *             if not read.is_del:
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:
 */
    __pyx_t_10 = ((__pyx_v_min_baseq > 0) != 0);
    if (__pyx_t_10) {

      /* "pysamstats/opt.pyx":1900
 *                 continue
 *         if min_baseq > 0:
 *             if not read.is_del:             # <<<<<<<<<<<<<<
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:
 *                     continue
 */
      __pyx_t_10 = ((!(__pyx_v_read->is_del != 0)) != 0);
      if (__pyx_t_10) {

        /* "pysamstats/opt.pyx":1901
 *         if min_baseq > 0:
 *             if not read.is_del:
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:             # <<<<<<<<<<<<<<
 *                     continue
 *         if no_del:
 */
        __pyx_t_10 = (((pysam_bam_get_qual(__pyx_v_read->b)[__pyx_v_read->qpos]) < __pyx_v_min_baseq) != 0);
        if (__pyx_t_10) {

          /* "pysamstats/opt.pyx":1902
 *             if not read.is_del:
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:
 *                     continue             # <<<<<<<<<<<<<<
 *         if no_del:
 *             if read.is_del:
 */
          goto __pyx_L3_continue;

          /* "pysamstats/opt.pyx":1901
 *         if min_baseq > 0:
 *             if not read.is_del:
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:             # <<<<<<<<<<<<<<
 *                     continue
 *         if no_del:
 */
        }

        /* "pysamstats/opt.pyx":1900
 *                 continue
 *         if min_baseq > 0:
 *             if not read.is_del:             # <<<<<<<<<<<<<<
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:
 *                     continue
 */
      }

      /* "pysamstats/opt.pyx":1899
 *             if b.core.qual < min_mapq:
 *                 continue
 *         if min_baseq > 0:             # <<<<<<<<<<<<<<
 *             if not read.is_del:
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:
 */
    }

    /* "pysamstats/opt.pyx":1903
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:
 *                     continue
 *         if no_del:             # <<<<<<<<<<<<<<
 *             if read.is_del:
 *                 continue
 */
    __pyx_t_10 = (__pyx_v_no_del != 0);
    if (__pyx_t_10) {

      /* "pysamstats/opt.pyx":1904
 *                     continue
 *         if no_del:
 *             if read.is_del:             # <<<<<<<<<<<<<<
 *                 continue
 *         if no_dup:
 */
      __pyx_t_10 = (__pyx_v_read->is_del != 0);
      if (__pyx_t_10) {

        /* "pysamstats/opt.pyx":1905
 *         if no_del:
 *             if read.is_del:
 *                 continue             # <<<<<<<<<<<<<<
 *         if no_dup:
 *             if b.core.flag & BAM_FDUP:
 */
        goto __pyx_L3_continue;

        /* "pysamstats/opt.pyx":1904
 *                     continue
 *         if no_del:
 *             if read.is_del:             # <<<<<<<<<<<<<<
 *                 continue
 *         if no_dup:
 */
      }

      /* "pysamstats/opt.pyx":1903
 *                 if pysam_bam_get_qual(read.b)[read.qpos] < min_baseq:
 *                     continue
 *         if no_del:             # <<<<<<<<<<<<<<
 *             if read.is_del:
 *                 continue
 */
    }

    /* "pysamstats/opt.pyx":1906
 *             if read.is_del:
 *                 continue
 *         if no_dup:             # <<<<<<<<<<<<<<
 *             if b.core.flag & BAM_FDUP:
 *                 continue
 */
    __pyx_t_10 = (__pyx_v_no_dup != 0);
    if (__pyx_t_10) {

      /* "pysamstats/opt.pyx":1907
 *                 continue
 *         if no_dup:
 *             if b.core.flag & BAM_FDUP:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      __pyx_t_10 = ((__pyx_v_b->core.flag & 0x400) != 0);
      if (__pyx_t_10) {

        /* "pysamstats/opt.pyx":1908
 *         if no_dup:
 *             if b.core.flag & BAM_FDUP:
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *         # accumulate statistics
 */
        goto __pyx_L3_continue;

        /* "pysamstats/opt.pyx":1907
 *                 continue
 *         if no_dup:
 *             if b.core.flag & BAM_FDUP:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      }

      /* "pysamstats/opt.pyx":1906
 *             if read.is_del:
 *                 continue
 *         if no_dup:             # <<<<<<<<<<<<<<
 *             if b.core.flag & BAM_FDUP:
 *                 continue
 */
    }

    /* "pysamstats/opt.pyx":1911
 * 
 *         # accumulate statistics
 *         stat.recv(read, col, refbase)             # <<<<<<<<<<<<<<
 * 
 *     # construct record
 */
    if (!(likely(PyBytes_CheckExact(__pyx_v_refbase))||((__pyx_v_refbase) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_refbase)->tp_name), 0))) __PYX_ERR(0, 1911, __pyx_L1_error)
    ((struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat *)__pyx_v_stat->__pyx_vtab)->recv(__pyx_v_stat, __pyx_v_read, __pyx_v_col, ((PyObject*)__pyx_v_refbase));
    __pyx_L3_continue:;
  }

  /* "pysamstats/opt.pyx":1914
 * 
 *     # construct record
 *     rec = stat.rec(chrom, col.pos, fafile, refbase)             # <<<<<<<<<<<<<<
 *     pos = col.pos + 1 if one_based else col.pos
 *     rec['chrom'] = chrom
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_col->pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyBytes_CheckExact(__pyx_v_refbase))||((__pyx_v_refbase) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_refbase)->tp_name), 0))) __PYX_ERR(0, 1914, __pyx_L1_error)
  __pyx_t_4 = ((struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat *)__pyx_v_stat->__pyx_vtab)->rec(__pyx_v_stat, __pyx_v_chrom, __pyx_t_1, __pyx_v_fafile, ((PyObject*)__pyx_v_refbase)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_rec = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "pysamstats/opt.pyx":1915
 *     # construct record
 *     rec = stat.rec(chrom, col.pos, fafile, refbase)
 *     pos = col.pos + 1 if one_based else col.pos             # <<<<<<<<<<<<<<
 *     rec['chrom'] = chrom
 *     rec['pos'] = pos
 */
  if ((__pyx_v_one_based != 0)) {
    __pyx_t_11 = (__pyx_v_col->pos + 1);
  } else {
    __pyx_t_11 = __pyx_v_col->pos;
  }
  __pyx_v_pos = __pyx_t_11;

  /* "pysamstats/opt.pyx":1916
 *     rec = stat.rec(chrom, col.pos, fafile, refbase)
 *     pos = col.pos + 1 if one_based else col.pos
 *     rec['chrom'] = chrom             # <<<<<<<<<<<<<<
 *     rec['pos'] = pos
 *     return rec
 */
  if (unlikely(__pyx_v_rec == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1916, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_n_s_chrom, __pyx_v_chrom) < 0)) __PYX_ERR(0, 1916, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1917
 *     pos = col.pos + 1 if one_based else col.pos
 *     rec['chrom'] = chrom
 *     rec['pos'] = pos             # <<<<<<<<<<<<<<
 *     return rec
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1917, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (unlikely(__pyx_v_rec == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1917, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_rec, __pyx_n_s_pos, __pyx_t_4) < 0)) __PYX_ERR(0, 1917, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "pysamstats/opt.pyx":1918
 *     rec['chrom'] = chrom
 *     rec['pos'] = pos
 *     return rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_rec);
  __pyx_r = __pyx_v_rec;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1865
 * 
 * 
 * def stat_pileup(PileupStat stat,             # <<<<<<<<<<<<<<
 *                 PileupColumn col,
 *                 AlignmentFile alignmentfile,
 */

  /* 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_AddTraceback("pysamstats.opt.stat_pileup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_refbase);
  __Pyx_XDECREF(__pyx_v_rec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1921
 * 
 * 
 * def iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs):             # <<<<<<<<<<<<<<
 *     if chrom is not None:
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_8iter_pileup_padded(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_7iter_pileup_padded[] = "iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_8iter_pileup_padded = {"iter_pileup_padded", (PyCFunction)__pyx_pw_10pysamstats_3opt_8iter_pileup_padded, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_7iter_pileup_padded};
static PyObject *__pyx_pw_10pysamstats_3opt_8iter_pileup_padded(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stat = 0;
  PyObject *__pyx_v_alignmentfile = 0;
  PyObject *__pyx_v_fafile = 0;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_pileup_padded (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stat,&__pyx_n_s_alignmentfile,&__pyx_n_s_fafile,&__pyx_n_s_chrom,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_stat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alignmentfile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded", 1, 4, 4, 1); __PYX_ERR(0, 1921, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fafile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded", 1, 4, 4, 2); __PYX_ERR(0, 1921, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chrom)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded", 1, 4, 4, 3); __PYX_ERR(0, 1921, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "iter_pileup_padded") < 0)) __PYX_ERR(0, 1921, __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_stat = values[0];
    __pyx_v_alignmentfile = values[1];
    __pyx_v_fafile = values[2];
    __pyx_v_chrom = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iter_pileup_padded", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1921, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysamstats.opt.iter_pileup_padded", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10pysamstats_3opt_7iter_pileup_padded(__pyx_self, __pyx_v_stat, __pyx_v_alignmentfile, __pyx_v_fafile, __pyx_v_chrom, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_10pysamstats_3opt_7iter_pileup_padded(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_it = NULL;
  PyObject *__pyx_v_its = NULL;
  PyObject *__pyx_v_itc = NULL;
  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;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("iter_pileup_padded", 0);
  __Pyx_INCREF(__pyx_v_chrom);

  /* "pysamstats/opt.pyx":1922
 * 
 * def iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs):
 *     if chrom is not None:             # <<<<<<<<<<<<<<
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                       chrom=chrom, **kwargs)
 */
  __pyx_t_1 = (__pyx_v_chrom != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1923
 * def iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs):
 *     if chrom is not None:
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                                       chrom=chrom, **kwargs)
 *     else:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_iter_pileup_padded_chrom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1923, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1923, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_stat);
    __Pyx_GIVEREF(__pyx_v_stat);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stat);
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1923, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_alignmentfile, __pyx_v_alignmentfile) < 0) __PYX_ERR(0, 1923, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_fafile, __pyx_v_fafile) < 0) __PYX_ERR(0, 1923, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1924
 *     if chrom is not None:
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                       chrom=chrom, **kwargs)             # <<<<<<<<<<<<<<
 *     else:
 *         its = list()
 */
    if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_chrom, __pyx_v_chrom) < 0) __PYX_ERR(0, 1923, __pyx_L1_error)
    __pyx_t_5 = __pyx_t_6;
    __pyx_t_6 = 0;
    if (__Pyx_MergeKeywords(__pyx_t_5, __pyx_v_kwargs) < 0) __PYX_ERR(0, 1924, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1923
 * def iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs):
 *     if chrom is not None:
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                                       chrom=chrom, **kwargs)
 *     else:
 */
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1923, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_it = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "pysamstats/opt.pyx":1922
 * 
 * def iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs):
 *     if chrom is not None:             # <<<<<<<<<<<<<<
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                       chrom=chrom, **kwargs)
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":1926
 *                                       chrom=chrom, **kwargs)
 *     else:
 *         its = list()             # <<<<<<<<<<<<<<
 *         for chrom in alignmentfile.references:
 *             itc = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 */
  /*else*/ {
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1926, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_v_its = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysamstats/opt.pyx":1927
 *     else:
 *         its = list()
 *         for chrom in alignmentfile.references:             # <<<<<<<<<<<<<<
 *             itc = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                            chrom=chrom, **kwargs)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_alignmentfile, __pyx_n_s_references); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1927, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
      __pyx_t_5 = __pyx_t_6; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1927, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1927, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 1927, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1927, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        } else {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 1927, __pyx_L1_error)
          #else
          __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1927, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
        }
      } else {
        __pyx_t_6 = __pyx_t_8(__pyx_t_5);
        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_ERR(0, 1927, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_DECREF_SET(__pyx_v_chrom, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "pysamstats/opt.pyx":1928
 *         its = list()
 *         for chrom in alignmentfile.references:
 *             itc = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                                            chrom=chrom, **kwargs)
 *             its.append(itc)
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_iter_pileup_padded_chrom); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1928, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1928, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_stat);
      __Pyx_GIVEREF(__pyx_v_stat);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stat);
      __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1928, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_alignmentfile, __pyx_v_alignmentfile) < 0) __PYX_ERR(0, 1928, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_fafile, __pyx_v_fafile) < 0) __PYX_ERR(0, 1928, __pyx_L1_error)

      /* "pysamstats/opt.pyx":1929
 *         for chrom in alignmentfile.references:
 *             itc = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                            chrom=chrom, **kwargs)             # <<<<<<<<<<<<<<
 *             its.append(itc)
 *         it = itertools.chain(*its)
 */
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_chrom, __pyx_v_chrom) < 0) __PYX_ERR(0, 1928, __pyx_L1_error)
      __pyx_t_3 = __pyx_t_9;
      __pyx_t_9 = 0;
      if (__Pyx_MergeKeywords(__pyx_t_3, __pyx_v_kwargs) < 0) __PYX_ERR(0, 1929, __pyx_L1_error)

      /* "pysamstats/opt.pyx":1928
 *         its = list()
 *         for chrom in alignmentfile.references:
 *             itc = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                                            chrom=chrom, **kwargs)
 *             its.append(itc)
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1928, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_itc, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "pysamstats/opt.pyx":1930
 *             itc = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                            chrom=chrom, **kwargs)
 *             its.append(itc)             # <<<<<<<<<<<<<<
 *         it = itertools.chain(*its)
 *     return it
 */
      __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_its, __pyx_v_itc); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 1930, __pyx_L1_error)

      /* "pysamstats/opt.pyx":1927
 *     else:
 *         its = list()
 *         for chrom in alignmentfile.references:             # <<<<<<<<<<<<<<
 *             itc = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                            chrom=chrom, **kwargs)
 */
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "pysamstats/opt.pyx":1931
 *                                            chrom=chrom, **kwargs)
 *             its.append(itc)
 *         it = itertools.chain(*its)             # <<<<<<<<<<<<<<
 *     return it
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_itertools); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_chain); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PySequence_Tuple(__pyx_v_its); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1931, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_it = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":1932
 *             its.append(itc)
 *         it = itertools.chain(*its)
 *     return it             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_it);
  __pyx_r = __pyx_v_it;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1921
 * 
 * 
 * def iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs):             # <<<<<<<<<<<<<<
 *     if chrom is not None:
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 */

  /* 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_9);
  __Pyx_AddTraceback("pysamstats.opt.iter_pileup_padded", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_it);
  __Pyx_XDECREF(__pyx_v_its);
  __Pyx_XDECREF(__pyx_v_itc);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10pysamstats_3opt_11generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "pysamstats/opt.pyx":1935
 * 
 * 
 * def iter_pileup_padded_chrom(PileupStat stat, alignmentfile, fafile, chrom, start, end,             # <<<<<<<<<<<<<<
 *                              one_based, truncate, max_depth, min_mapq, min_baseq, no_del, no_dup):
 *     cdef:
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_10iter_pileup_padded_chrom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_9iter_pileup_padded_chrom[] = "iter_pileup_padded_chrom(PileupStat stat, alignmentfile, fafile, chrom, start, end, one_based, truncate, max_depth, min_mapq, min_baseq, no_del, no_dup)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_10iter_pileup_padded_chrom = {"iter_pileup_padded_chrom", (PyCFunction)__pyx_pw_10pysamstats_3opt_10iter_pileup_padded_chrom, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_9iter_pileup_padded_chrom};
static PyObject *__pyx_pw_10pysamstats_3opt_10iter_pileup_padded_chrom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_stat = 0;
  PyObject *__pyx_v_alignmentfile = 0;
  PyObject *__pyx_v_fafile = 0;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_end = 0;
  PyObject *__pyx_v_one_based = 0;
  PyObject *__pyx_v_truncate = 0;
  PyObject *__pyx_v_max_depth = 0;
  PyObject *__pyx_v_min_mapq = 0;
  PyObject *__pyx_v_min_baseq = 0;
  PyObject *__pyx_v_no_del = 0;
  PyObject *__pyx_v_no_dup = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_pileup_padded_chrom (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stat,&__pyx_n_s_alignmentfile,&__pyx_n_s_fafile,&__pyx_n_s_chrom,&__pyx_n_s_start,&__pyx_n_s_end,&__pyx_n_s_one_based,&__pyx_n_s_truncate,&__pyx_n_s_max_depth,&__pyx_n_s_min_mapq,&__pyx_n_s_min_baseq,&__pyx_n_s_no_del,&__pyx_n_s_no_dup,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,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 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alignmentfile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 1); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fafile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 2); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chrom)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 3); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 4); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 5); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_one_based)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 6); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_truncate)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 7); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_max_depth)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 8); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case  9:
        if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_mapq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 9); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case 10:
        if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_baseq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 10); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case 11:
        if (likely((values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_no_del)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 11); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
        case 12:
        if (likely((values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_no_dup)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, 12); __PYX_ERR(0, 1935, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iter_pileup_padded_chrom") < 0)) __PYX_ERR(0, 1935, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 13) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
    }
    __pyx_v_stat = ((struct __pyx_obj_10pysamstats_3opt_PileupStat *)values[0]);
    __pyx_v_alignmentfile = values[1];
    __pyx_v_fafile = values[2];
    __pyx_v_chrom = values[3];
    __pyx_v_start = values[4];
    __pyx_v_end = values[5];
    __pyx_v_one_based = values[6];
    __pyx_v_truncate = values[7];
    __pyx_v_max_depth = values[8];
    __pyx_v_min_mapq = values[9];
    __pyx_v_min_baseq = values[10];
    __pyx_v_no_del = values[11];
    __pyx_v_no_dup = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iter_pileup_padded_chrom", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1935, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.iter_pileup_padded_chrom", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stat), __pyx_ptype_10pysamstats_3opt_PileupStat, 1, "stat", 0))) __PYX_ERR(0, 1935, __pyx_L1_error)
  __pyx_r = __pyx_pf_10pysamstats_3opt_9iter_pileup_padded_chrom(__pyx_self, __pyx_v_stat, __pyx_v_alignmentfile, __pyx_v_fafile, __pyx_v_chrom, __pyx_v_start, __pyx_v_end, __pyx_v_one_based, __pyx_v_truncate, __pyx_v_max_depth, __pyx_v_min_mapq, __pyx_v_min_baseq, __pyx_v_no_del, __pyx_v_no_dup);

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

static PyObject *__pyx_pf_10pysamstats_3opt_9iter_pileup_padded_chrom(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_10pysamstats_3opt_PileupStat *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_one_based, PyObject *__pyx_v_truncate, PyObject *__pyx_v_max_depth, PyObject *__pyx_v_min_mapq, PyObject *__pyx_v_min_baseq, PyObject *__pyx_v_no_del, PyObject *__pyx_v_no_dup) {
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_pileup_padded_chrom", 0);
  __pyx_cur_scope = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *)__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom(__pyx_ptype_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1935, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_stat = __pyx_v_stat;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_stat);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_stat);
  __pyx_cur_scope->__pyx_v_alignmentfile = __pyx_v_alignmentfile;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_alignmentfile);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_alignmentfile);
  __pyx_cur_scope->__pyx_v_fafile = __pyx_v_fafile;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fafile);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fafile);
  __pyx_cur_scope->__pyx_v_chrom = __pyx_v_chrom;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
  __pyx_cur_scope->__pyx_v_start = __pyx_v_start;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
  __pyx_cur_scope->__pyx_v_end = __pyx_v_end;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end);
  __pyx_cur_scope->__pyx_v_one_based = __pyx_v_one_based;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_one_based);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_one_based);
  __pyx_cur_scope->__pyx_v_truncate = __pyx_v_truncate;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_truncate);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_truncate);
  __pyx_cur_scope->__pyx_v_max_depth = __pyx_v_max_depth;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_max_depth);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_max_depth);
  __pyx_cur_scope->__pyx_v_min_mapq = __pyx_v_min_mapq;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_min_mapq);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_min_mapq);
  __pyx_cur_scope->__pyx_v_min_baseq = __pyx_v_min_baseq;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_min_baseq);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_min_baseq);
  __pyx_cur_scope->__pyx_v_no_del = __pyx_v_no_del;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_no_del);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_no_del);
  __pyx_cur_scope->__pyx_v_no_dup = __pyx_v_no_dup;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_no_dup);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_no_dup);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10pysamstats_3opt_11generator1, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter_pileup_padded_chrom, __pyx_n_s_iter_pileup_padded_chrom, __pyx_n_s_pysamstats_opt); if (unlikely(!gen)) __PYX_ERR(0, 1935, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysamstats.opt.iter_pileup_padded_chrom", __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_10pysamstats_3opt_11generator1(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *__pyx_cur_scope = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  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)(PyObject *);
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  long __pyx_t_12;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_yield;
    case 2: goto __pyx_L11_resume_from_yield;
    case 3: goto __pyx_L14_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1935, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1942
 * 
 *     # obtain pileup iterator
 *     assert chrom is not None, 'chromosome is None'             # <<<<<<<<<<<<<<
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (__pyx_cur_scope->__pyx_v_chrom != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_chromosome_is_None);
      __PYX_ERR(0, 1942, __pyx_L1_error)
    }
  }
  #endif

  /* "pysamstats/opt.pyx":1943
 *     # obtain pileup iterator
 *     assert chrom is not None, 'chromosome is None'
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)             # <<<<<<<<<<<<<<
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,
 *                               max_depth=max_depth)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_normalise_coords); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1943, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_alignmentfile, __pyx_cur_scope->__pyx_v_chrom, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_end, __pyx_cur_scope->__pyx_v_one_based};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1943, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[6] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_alignmentfile, __pyx_cur_scope->__pyx_v_chrom, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_end, __pyx_cur_scope->__pyx_v_one_based};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1943, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1943, __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_cur_scope->__pyx_v_alignmentfile);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_alignmentfile);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_cur_scope->__pyx_v_alignmentfile);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_cur_scope->__pyx_v_chrom);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_cur_scope->__pyx_v_start);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end);
    PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_cur_scope->__pyx_v_end);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_one_based);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_one_based);
    PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_cur_scope->__pyx_v_one_based);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1943, __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;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    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_ERR(0, 1943, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1943, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1943, __pyx_L1_error)
    __pyx_L5_unpacking_done:;
  }
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_end);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_end, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pysamstats/opt.pyx":1944
 *     assert chrom is not None, 'chromosome is None'
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,             # <<<<<<<<<<<<<<
 *                               max_depth=max_depth)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_alignmentfile, __pyx_n_s_pileup); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_reference, __pyx_cur_scope->__pyx_v_chrom) < 0) __PYX_ERR(0, 1944, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_start, __pyx_cur_scope->__pyx_v_start) < 0) __PYX_ERR(0, 1944, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_end, __pyx_cur_scope->__pyx_v_end) < 0) __PYX_ERR(0, 1944, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_truncate, __pyx_cur_scope->__pyx_v_truncate) < 0) __PYX_ERR(0, 1944, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1945
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,
 *                               max_depth=max_depth)             # <<<<<<<<<<<<<<
 * 
 *     # keep track of current position
 */
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_max_depth, __pyx_cur_scope->__pyx_v_max_depth) < 0) __PYX_ERR(0, 1944, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1944
 *     assert chrom is not None, 'chromosome is None'
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)
 *     it = alignmentfile.pileup(reference=chrom, start=start, end=end, truncate=truncate,             # <<<<<<<<<<<<<<
 *                               max_depth=max_depth)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_it = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1948
 * 
 *     # keep track of current position
 *     curpos = start             # <<<<<<<<<<<<<<
 * 
 *     # iterate over pileup columns
 */
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_cur_scope->__pyx_v_start); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1948, __pyx_L1_error)
  __pyx_cur_scope->__pyx_v_curpos = __pyx_t_5;

  /* "pysamstats/opt.pyx":1951
 * 
 *     # iterate over pileup columns
 *     for col in it:             # <<<<<<<<<<<<<<
 * 
 *         # pad up to next pileup column
 */
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_it)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_it)) {
    __pyx_t_3 = __pyx_cur_scope->__pyx_v_it; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_it); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1951, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1951, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1951, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1951, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1951, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1951, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_9(__pyx_t_3);
      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_ERR(0, 1951, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5pysam_18libcalignedsegment_PileupColumn))))) __PYX_ERR(0, 1951, __pyx_L1_error)
    __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_col));
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_col, ((struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *)__pyx_t_6));
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;

    /* "pysamstats/opt.pyx":1954
 * 
 *         # pad up to next pileup column
 *         while curpos < col.pos:             # <<<<<<<<<<<<<<
 *             # setup reference base
 *             refbase = get_refbase(fafile, chrom, curpos)
 */
    while (1) {
      __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_curpos < __pyx_cur_scope->__pyx_v_col->pos) != 0);
      if (!__pyx_t_1) break;

      /* "pysamstats/opt.pyx":1956
 *         while curpos < col.pos:
 *             # setup reference base
 *             refbase = get_refbase(fafile, chrom, curpos)             # <<<<<<<<<<<<<<
 *             # construct record
 *             rec = stat.rec(chrom, curpos, fafile, refbase)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_refbase); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1956, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_curpos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1956, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_fafile, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_4};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1956, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_fafile, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_4};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1956, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1956, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fafile);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fafile);
        PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_5, __pyx_cur_scope->__pyx_v_fafile);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_5, __pyx_cur_scope->__pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_5, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1956, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_refbase);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_refbase, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;

      /* "pysamstats/opt.pyx":1958
 *             refbase = get_refbase(fafile, chrom, curpos)
 *             # construct record
 *             rec = stat.rec(chrom, curpos, fafile, refbase)             # <<<<<<<<<<<<<<
 *             rec['chrom'] = chrom
 *             pos = curpos + 1 if one_based else curpos
 */
      __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_curpos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1958, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (!(likely(((__pyx_cur_scope->__pyx_v_fafile) == Py_None) || likely(__Pyx_TypeTest(__pyx_cur_scope->__pyx_v_fafile, __pyx_ptype_5pysam_9libcfaidx_FastaFile))))) __PYX_ERR(0, 1958, __pyx_L1_error)
      if (!(likely(PyBytes_CheckExact(__pyx_cur_scope->__pyx_v_refbase))||((__pyx_cur_scope->__pyx_v_refbase) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_cur_scope->__pyx_v_refbase)->tp_name), 0))) __PYX_ERR(0, 1958, __pyx_L1_error)
      __pyx_t_2 = ((struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat *)__pyx_cur_scope->__pyx_v_stat->__pyx_vtab)->rec(__pyx_cur_scope->__pyx_v_stat, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_6, ((struct __pyx_obj_5pysam_9libcfaidx_FastaFile *)__pyx_cur_scope->__pyx_v_fafile), ((PyObject*)__pyx_cur_scope->__pyx_v_refbase)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1958, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_rec);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_rec, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;

      /* "pysamstats/opt.pyx":1959
 *             # construct record
 *             rec = stat.rec(chrom, curpos, fafile, refbase)
 *             rec['chrom'] = chrom             # <<<<<<<<<<<<<<
 *             pos = curpos + 1 if one_based else curpos
 *             rec['pos'] = pos
 */
      if (unlikely(PyObject_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_chrom, __pyx_cur_scope->__pyx_v_chrom) < 0)) __PYX_ERR(0, 1959, __pyx_L1_error)

      /* "pysamstats/opt.pyx":1960
 *             rec = stat.rec(chrom, curpos, fafile, refbase)
 *             rec['chrom'] = chrom
 *             pos = curpos + 1 if one_based else curpos             # <<<<<<<<<<<<<<
 *             rec['pos'] = pos
 *             yield rec
 */
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_one_based); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1960, __pyx_L1_error)
      if (__pyx_t_1) {
        __pyx_t_12 = (__pyx_cur_scope->__pyx_v_curpos + 1);
      } else {
        __pyx_t_12 = __pyx_cur_scope->__pyx_v_curpos;
      }
      __pyx_cur_scope->__pyx_v_pos = __pyx_t_12;

      /* "pysamstats/opt.pyx":1961
 *             rec['chrom'] = chrom
 *             pos = curpos + 1 if one_based else curpos
 *             rec['pos'] = pos             # <<<<<<<<<<<<<<
 *             yield rec
 *             curpos += 1
 */
      __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_cur_scope->__pyx_v_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1961, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(PyObject_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_pos, __pyx_t_2) < 0)) __PYX_ERR(0, 1961, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "pysamstats/opt.pyx":1962
 *             pos = curpos + 1 if one_based else curpos
 *             rec['pos'] = pos
 *             yield rec             # <<<<<<<<<<<<<<
 *             curpos += 1
 * 
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_rec);
      __pyx_r = __pyx_cur_scope->__pyx_v_rec;
      __Pyx_XGIVEREF(__pyx_t_3);
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L10_resume_from_yield:;
      __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
      __pyx_cur_scope->__pyx_t_0 = 0;
      __Pyx_XGOTREF(__pyx_t_3);
      __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1962, __pyx_L1_error)

      /* "pysamstats/opt.pyx":1963
 *             rec['pos'] = pos
 *             yield rec
 *             curpos += 1             # <<<<<<<<<<<<<<
 * 
 *         # construct and yield statistics record for current pileup column
 */
      __pyx_cur_scope->__pyx_v_curpos = (__pyx_cur_scope->__pyx_v_curpos + 1);
    }

    /* "pysamstats/opt.pyx":1966
 * 
 *         # construct and yield statistics record for current pileup column
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,
 *                           no_del=no_del, no_dup=no_dup)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stat_pileup); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1966, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1966, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_stat));
    __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_stat));
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_stat));
    __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_col));
    __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_col));
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_cur_scope->__pyx_v_col));
    __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1966, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_alignmentfile, __pyx_cur_scope->__pyx_v_alignmentfile) < 0) __PYX_ERR(0, 1966, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_fafile, __pyx_cur_scope->__pyx_v_fafile) < 0) __PYX_ERR(0, 1966, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1967
 *         # construct and yield statistics record for current pileup column
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,             # <<<<<<<<<<<<<<
 *                           no_del=no_del, no_dup=no_dup)
 *         yield rec
 */
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_one_based, __pyx_cur_scope->__pyx_v_one_based) < 0) __PYX_ERR(0, 1966, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_min_mapq, __pyx_cur_scope->__pyx_v_min_mapq) < 0) __PYX_ERR(0, 1966, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_min_baseq, __pyx_cur_scope->__pyx_v_min_baseq) < 0) __PYX_ERR(0, 1966, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1968
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,
 *                           no_del=no_del, no_dup=no_dup)             # <<<<<<<<<<<<<<
 *         yield rec
 * 
 */
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_no_del, __pyx_cur_scope->__pyx_v_no_del) < 0) __PYX_ERR(0, 1966, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_no_dup, __pyx_cur_scope->__pyx_v_no_dup) < 0) __PYX_ERR(0, 1966, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1966
 * 
 *         # construct and yield statistics record for current pileup column
 *         rec = stat_pileup(stat, col, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,
 *                           no_del=no_del, no_dup=no_dup)
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1966, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_rec);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_rec, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysamstats/opt.pyx":1969
 *                           one_based=one_based, min_mapq=min_mapq, min_baseq=min_baseq,
 *                           no_del=no_del, no_dup=no_dup)
 *         yield rec             # <<<<<<<<<<<<<<
 * 
 *         # advance current position
 */
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_rec);
    __pyx_r = __pyx_cur_scope->__pyx_v_rec;
    __Pyx_XGIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L11_resume_from_yield:;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_3);
    __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1969, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1972
 * 
 *         # advance current position
 *         curpos = col.pos + 1             # <<<<<<<<<<<<<<
 * 
 *     while curpos < end:
 */
    __pyx_cur_scope->__pyx_v_curpos = (__pyx_cur_scope->__pyx_v_col->pos + 1);

    /* "pysamstats/opt.pyx":1951
 * 
 *     # iterate over pileup columns
 *     for col in it:             # <<<<<<<<<<<<<<
 * 
 *         # pad up to next pileup column
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":1974
 *         curpos = col.pos + 1
 * 
 *     while curpos < end:             # <<<<<<<<<<<<<<
 * 
 *         # pad out to end position
 */
  while (1) {
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_curpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1974, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_cur_scope->__pyx_v_end, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1974, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1974, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!__pyx_t_1) break;

    /* "pysamstats/opt.pyx":1977
 * 
 *         # pad out to end position
 *         refbase = get_refbase(fafile, chrom, curpos)             # <<<<<<<<<<<<<<
 *         rec = stat.rec(chrom, curpos, fafile, refbase)
 *         rec['chrom'] = chrom
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_get_refbase); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1977, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_curpos); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1977, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_fafile, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_11};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1977, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_fafile, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_11};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1977, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1977, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fafile);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fafile);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_5, __pyx_cur_scope->__pyx_v_fafile);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_5, __pyx_cur_scope->__pyx_v_chrom);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_5, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1977, __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_XGOTREF(__pyx_cur_scope->__pyx_v_refbase);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_refbase, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysamstats/opt.pyx":1978
 *         # pad out to end position
 *         refbase = get_refbase(fafile, chrom, curpos)
 *         rec = stat.rec(chrom, curpos, fafile, refbase)             # <<<<<<<<<<<<<<
 *         rec['chrom'] = chrom
 *         pos = curpos + 1 if one_based else curpos
 */
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_curpos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1978, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(((__pyx_cur_scope->__pyx_v_fafile) == Py_None) || likely(__Pyx_TypeTest(__pyx_cur_scope->__pyx_v_fafile, __pyx_ptype_5pysam_9libcfaidx_FastaFile))))) __PYX_ERR(0, 1978, __pyx_L1_error)
    if (!(likely(PyBytes_CheckExact(__pyx_cur_scope->__pyx_v_refbase))||((__pyx_cur_scope->__pyx_v_refbase) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_cur_scope->__pyx_v_refbase)->tp_name), 0))) __PYX_ERR(0, 1978, __pyx_L1_error)
    __pyx_t_3 = ((struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat *)__pyx_cur_scope->__pyx_v_stat->__pyx_vtab)->rec(__pyx_cur_scope->__pyx_v_stat, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_4, ((struct __pyx_obj_5pysam_9libcfaidx_FastaFile *)__pyx_cur_scope->__pyx_v_fafile), ((PyObject*)__pyx_cur_scope->__pyx_v_refbase)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1978, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_rec);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_rec, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "pysamstats/opt.pyx":1979
 *         refbase = get_refbase(fafile, chrom, curpos)
 *         rec = stat.rec(chrom, curpos, fafile, refbase)
 *         rec['chrom'] = chrom             # <<<<<<<<<<<<<<
 *         pos = curpos + 1 if one_based else curpos
 *         rec['pos'] = pos
 */
    if (unlikely(PyObject_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_chrom, __pyx_cur_scope->__pyx_v_chrom) < 0)) __PYX_ERR(0, 1979, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1980
 *         rec = stat.rec(chrom, curpos, fafile, refbase)
 *         rec['chrom'] = chrom
 *         pos = curpos + 1 if one_based else curpos             # <<<<<<<<<<<<<<
 *         rec['pos'] = pos
 *         yield rec
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_one_based); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 1980, __pyx_L1_error)
    if (__pyx_t_1) {
      __pyx_t_12 = (__pyx_cur_scope->__pyx_v_curpos + 1);
    } else {
      __pyx_t_12 = __pyx_cur_scope->__pyx_v_curpos;
    }
    __pyx_cur_scope->__pyx_v_pos = __pyx_t_12;

    /* "pysamstats/opt.pyx":1981
 *         rec['chrom'] = chrom
 *         pos = curpos + 1 if one_based else curpos
 *         rec['pos'] = pos             # <<<<<<<<<<<<<<
 *         yield rec
 *         curpos += 1
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_cur_scope->__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1981, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(PyObject_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_pos, __pyx_t_3) < 0)) __PYX_ERR(0, 1981, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "pysamstats/opt.pyx":1982
 *         pos = curpos + 1 if one_based else curpos
 *         rec['pos'] = pos
 *         yield rec             # <<<<<<<<<<<<<<
 *         curpos += 1
 * 
 */
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_rec);
    __pyx_r = __pyx_cur_scope->__pyx_v_rec;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 3;
    return __pyx_r;
    __pyx_L14_resume_from_yield:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1982, __pyx_L1_error)

    /* "pysamstats/opt.pyx":1983
 *         rec['pos'] = pos
 *         yield rec
 *         curpos += 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_cur_scope->__pyx_v_curpos = (__pyx_cur_scope->__pyx_v_curpos + 1);
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysamstats/opt.pyx":1935
 * 
 * 
 * def iter_pileup_padded_chrom(PileupStat stat, alignmentfile, fafile, chrom, start, end,             # <<<<<<<<<<<<<<
 *                              one_based, truncate, max_depth, min_mapq, min_baseq, no_del, no_dup):
 *     cdef:
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("iter_pileup_padded_chrom", __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;
}

/* "pysamstats/opt.pyx":1986
 * 
 * 
 * def get_refbase(fafile, chrom, pos):             # <<<<<<<<<<<<<<
 *     if fafile is not None:
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_13get_refbase(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_12get_refbase[] = "get_refbase(fafile, chrom, pos)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_13get_refbase = {"get_refbase", (PyCFunction)__pyx_pw_10pysamstats_3opt_13get_refbase, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_12get_refbase};
static PyObject *__pyx_pw_10pysamstats_3opt_13get_refbase(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_fafile = 0;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_pos = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_refbase (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fafile,&__pyx_n_s_chrom,&__pyx_n_s_pos,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_fafile)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chrom)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_refbase", 1, 3, 3, 1); __PYX_ERR(0, 1986, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pos)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_refbase", 1, 3, 3, 2); __PYX_ERR(0, 1986, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_refbase") < 0)) __PYX_ERR(0, 1986, __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_fafile = values[0];
    __pyx_v_chrom = values[1];
    __pyx_v_pos = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_refbase", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1986, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.get_refbase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10pysamstats_3opt_12get_refbase(__pyx_self, __pyx_v_fafile, __pyx_v_chrom, __pyx_v_pos);

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

static PyObject *__pyx_pf_10pysamstats_3opt_12get_refbase(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_pos) {
  PyObject *__pyx_v_refbase = NULL;
  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;
  __Pyx_RefNannySetupContext("get_refbase", 0);

  /* "pysamstats/opt.pyx":1987
 * 
 * def get_refbase(fafile, chrom, pos):
 *     if fafile is not None:             # <<<<<<<<<<<<<<
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 *         if not PY2:
 */
  __pyx_t_1 = (__pyx_v_fafile != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":1988
 * def get_refbase(fafile, chrom, pos):
 *     if fafile is not None:
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()             # <<<<<<<<<<<<<<
 *         if not PY2:
 *             refbase = refbase.encode('ascii')
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_fafile, __pyx_n_s_fetch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1988, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1988, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_reference, __pyx_v_chrom) < 0) __PYX_ERR(0, 1988, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_start, __pyx_v_pos) < 0) __PYX_ERR(0, 1988, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_pos, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1988, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_end, __pyx_t_6) < 0) __PYX_ERR(0, 1988, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1988, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_upper); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1988, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1988, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1988, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_refbase = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "pysamstats/opt.pyx":1989
 *     if fafile is not None:
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 *         if not PY2:             # <<<<<<<<<<<<<<
 *             refbase = refbase.encode('ascii')
 *     else:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1989, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1989, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = ((!__pyx_t_2) != 0);
    if (__pyx_t_1) {

      /* "pysamstats/opt.pyx":1990
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 *         if not PY2:
 *             refbase = refbase.encode('ascii')             # <<<<<<<<<<<<<<
 *     else:
 *         refbase = None
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_refbase, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_refbase, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "pysamstats/opt.pyx":1989
 *     if fafile is not None:
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 *         if not PY2:             # <<<<<<<<<<<<<<
 *             refbase = refbase.encode('ascii')
 *     else:
 */
    }

    /* "pysamstats/opt.pyx":1987
 * 
 * def get_refbase(fafile, chrom, pos):
 *     if fafile is not None:             # <<<<<<<<<<<<<<
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 *         if not PY2:
 */
    goto __pyx_L3;
  }

  /* "pysamstats/opt.pyx":1992
 *             refbase = refbase.encode('ascii')
 *     else:
 *         refbase = None             # <<<<<<<<<<<<<<
 *     return refbase
 * 
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __pyx_v_refbase = Py_None;
  }
  __pyx_L3:;

  /* "pysamstats/opt.pyx":1993
 *     else:
 *         refbase = None
 *     return refbase             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_refbase);
  __pyx_r = __pyx_v_refbase;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1986
 * 
 * 
 * def get_refbase(fafile, chrom, pos):             # <<<<<<<<<<<<<<
 *     if fafile is not None:
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 */

  /* 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_AddTraceback("pysamstats.opt.get_refbase", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_refbase);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":1996
 * 
 * 
 * def iter_binned(stat, alignmentfile, fafile, chrom, window_size=300, window_offset=None,             # <<<<<<<<<<<<<<
 *                 **kwargs):
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_15iter_binned(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_14iter_binned[] = "iter_binned(stat, alignmentfile, fafile, chrom, window_size=300, window_offset=None, **kwargs)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_15iter_binned = {"iter_binned", (PyCFunction)__pyx_pw_10pysamstats_3opt_15iter_binned, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_14iter_binned};
static PyObject *__pyx_pw_10pysamstats_3opt_15iter_binned(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_stat = 0;
  PyObject *__pyx_v_alignmentfile = 0;
  PyObject *__pyx_v_fafile = 0;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_window_size = 0;
  PyObject *__pyx_v_window_offset = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_binned (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stat,&__pyx_n_s_alignmentfile,&__pyx_n_s_fafile,&__pyx_n_s_chrom,&__pyx_n_s_window_size,&__pyx_n_s_window_offset,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[4] = ((PyObject *)__pyx_int_300);
    values[5] = ((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  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alignmentfile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned", 0, 4, 6, 1); __PYX_ERR(0, 1996, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fafile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned", 0, 4, 6, 2); __PYX_ERR(0, 1996, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chrom)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned", 0, 4, 6, 3); __PYX_ERR(0, 1996, __pyx_L3_error)
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window_size);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window_offset);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "iter_binned") < 0)) __PYX_ERR(0, 1996, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        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_stat = values[0];
    __pyx_v_alignmentfile = values[1];
    __pyx_v_fafile = values[2];
    __pyx_v_chrom = values[3];
    __pyx_v_window_size = values[4];
    __pyx_v_window_offset = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iter_binned", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1996, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("pysamstats.opt.iter_binned", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10pysamstats_3opt_14iter_binned(__pyx_self, __pyx_v_stat, __pyx_v_alignmentfile, __pyx_v_fafile, __pyx_v_chrom, __pyx_v_window_size, __pyx_v_window_offset, __pyx_v_kwargs);

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

static PyObject *__pyx_pf_10pysamstats_3opt_14iter_binned(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_stat, PyObject *__pyx_v_alignmentfile, PyObject *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_window_size, PyObject *__pyx_v_window_offset, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_its = NULL;
  PyObject *__pyx_v_itc = NULL;
  PyObject *__pyx_v_it = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("iter_binned", 0);
  __Pyx_INCREF(__pyx_v_alignmentfile);
  __Pyx_INCREF(__pyx_v_fafile);
  __Pyx_INCREF(__pyx_v_chrom);
  __Pyx_INCREF(__pyx_v_window_offset);

  /* "pysamstats/opt.pyx":1999
 *                 **kwargs):
 * 
 *     if isinstance(alignmentfile, _string_types):             # <<<<<<<<<<<<<<
 *         alignmentfile = AlignmentFile(alignmentfile)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1999, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_alignmentfile, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 1999, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":2000
 * 
 *     if isinstance(alignmentfile, _string_types):
 *         alignmentfile = AlignmentFile(alignmentfile)             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(fafile, _string_types):
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_alignmentfile);
    __Pyx_GIVEREF(__pyx_v_alignmentfile);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_alignmentfile);
    __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile), __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2000, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_alignmentfile, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "pysamstats/opt.pyx":1999
 *                 **kwargs):
 * 
 *     if isinstance(alignmentfile, _string_types):             # <<<<<<<<<<<<<<
 *         alignmentfile = AlignmentFile(alignmentfile)
 * 
 */
  }

  /* "pysamstats/opt.pyx":2002
 *         alignmentfile = AlignmentFile(alignmentfile)
 * 
 *     if isinstance(fafile, _string_types):             # <<<<<<<<<<<<<<
 *         fafile = FastaFile(fafile)
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_string_types); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2002, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_fafile, __pyx_t_4); if (unlikely(__pyx_t_3 == -1)) __PYX_ERR(0, 2002, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":2003
 * 
 *     if isinstance(fafile, _string_types):
 *         fafile = FastaFile(fafile)             # <<<<<<<<<<<<<<
 * 
 *     if window_offset is None:
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2003, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_fafile);
    __Pyx_GIVEREF(__pyx_v_fafile);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fafile);
    __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5pysam_9libcfaidx_FastaFile), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2003, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_fafile, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pysamstats/opt.pyx":2002
 *         alignmentfile = AlignmentFile(alignmentfile)
 * 
 *     if isinstance(fafile, _string_types):             # <<<<<<<<<<<<<<
 *         fafile = FastaFile(fafile)
 * 
 */
  }

  /* "pysamstats/opt.pyx":2005
 *         fafile = FastaFile(fafile)
 * 
 *     if window_offset is None:             # <<<<<<<<<<<<<<
 *         window_offset = window_size / 2
 * 
 */
  __pyx_t_2 = (__pyx_v_window_offset == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":2006
 * 
 *     if window_offset is None:
 *         window_offset = window_size / 2             # <<<<<<<<<<<<<<
 * 
 *     if chrom is None:
 */
    __pyx_t_1 = __Pyx_PyInt_TrueDivideObjC(__pyx_v_window_size, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2006, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_window_offset, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "pysamstats/opt.pyx":2005
 *         fafile = FastaFile(fafile)
 * 
 *     if window_offset is None:             # <<<<<<<<<<<<<<
 *         window_offset = window_size / 2
 * 
 */
  }

  /* "pysamstats/opt.pyx":2008
 *         window_offset = window_size / 2
 * 
 *     if chrom is None:             # <<<<<<<<<<<<<<
 *         its = list()
 *         for chrom in alignmentfile.references:
 */
  __pyx_t_3 = (__pyx_v_chrom == Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":2009
 * 
 *     if chrom is None:
 *         its = list()             # <<<<<<<<<<<<<<
 *         for chrom in alignmentfile.references:
 *             itc = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2009, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_its = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "pysamstats/opt.pyx":2010
 *     if chrom is None:
 *         its = list()
 *         for chrom in alignmentfile.references:             # <<<<<<<<<<<<<<
 *             itc = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                     chrom=chrom, window_size=window_size,
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_alignmentfile, __pyx_n_s_references); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2010, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2010, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2010, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2010, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2010, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 2010, __pyx_L1_error)
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2010, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_6(__pyx_t_4);
        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_ERR(0, 2010, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF_SET(__pyx_v_chrom, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "pysamstats/opt.pyx":2011
 *         its = list()
 *         for chrom in alignmentfile.references:
 *             itc = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                                     chrom=chrom, window_size=window_size,
 *                                     window_offset=window_offset, **kwargs)
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_iter_binned_chrom); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2011, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2011, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_stat);
      __Pyx_GIVEREF(__pyx_v_stat);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_stat);
      __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2011, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_alignmentfile, __pyx_v_alignmentfile) < 0) __PYX_ERR(0, 2011, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_fafile, __pyx_v_fafile) < 0) __PYX_ERR(0, 2011, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2012
 *         for chrom in alignmentfile.references:
 *             itc = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                     chrom=chrom, window_size=window_size,             # <<<<<<<<<<<<<<
 *                                     window_offset=window_offset, **kwargs)
 *             its.append(itc)
 */
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_chrom, __pyx_v_chrom) < 0) __PYX_ERR(0, 2011, __pyx_L1_error)
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_window_size, __pyx_v_window_size) < 0) __PYX_ERR(0, 2011, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2013
 *             itc = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                     chrom=chrom, window_size=window_size,
 *                                     window_offset=window_offset, **kwargs)             # <<<<<<<<<<<<<<
 *             its.append(itc)
 *         it = itertools.chain(*its)
 */
      if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_window_offset, __pyx_v_window_offset) < 0) __PYX_ERR(0, 2011, __pyx_L1_error)
      __pyx_t_8 = __pyx_t_9;
      __pyx_t_9 = 0;
      if (__Pyx_MergeKeywords(__pyx_t_8, __pyx_v_kwargs) < 0) __PYX_ERR(0, 2013, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2011
 *         its = list()
 *         for chrom in alignmentfile.references:
 *             itc = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                                     chrom=chrom, window_size=window_size,
 *                                     window_offset=window_offset, **kwargs)
 */
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2011, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF_SET(__pyx_v_itc, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "pysamstats/opt.pyx":2014
 *                                     chrom=chrom, window_size=window_size,
 *                                     window_offset=window_offset, **kwargs)
 *             its.append(itc)             # <<<<<<<<<<<<<<
 *         it = itertools.chain(*its)
 * 
 */
      __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_its, __pyx_v_itc); if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 2014, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2010
 *     if chrom is None:
 *         its = list()
 *         for chrom in alignmentfile.references:             # <<<<<<<<<<<<<<
 *             itc = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                     chrom=chrom, window_size=window_size,
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "pysamstats/opt.pyx":2015
 *                                     window_offset=window_offset, **kwargs)
 *             its.append(itc)
 *         it = itertools.chain(*its)             # <<<<<<<<<<<<<<
 * 
 *     else:
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_itertools); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2015, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_chain); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2015, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PySequence_Tuple(__pyx_v_its); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2015, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2015, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_it = __pyx_t_8;
    __pyx_t_8 = 0;

    /* "pysamstats/opt.pyx":2008
 *         window_offset = window_size / 2
 * 
 *     if chrom is None:             # <<<<<<<<<<<<<<
 *         its = list()
 *         for chrom in alignmentfile.references:
 */
    goto __pyx_L6;
  }

  /* "pysamstats/opt.pyx":2018
 * 
 *     else:
 *         it = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                                chrom=chrom, window_size=window_size, window_offset=window_offset,
 *                                **kwargs)
 */
  /*else*/ {
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_iter_binned_chrom); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2018, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2018, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_stat);
    __Pyx_GIVEREF(__pyx_v_stat);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stat);
    __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2018, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_alignmentfile, __pyx_v_alignmentfile) < 0) __PYX_ERR(0, 2018, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_fafile, __pyx_v_fafile) < 0) __PYX_ERR(0, 2018, __pyx_L1_error)

    /* "pysamstats/opt.pyx":2019
 *     else:
 *         it = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                chrom=chrom, window_size=window_size, window_offset=window_offset,             # <<<<<<<<<<<<<<
 *                                **kwargs)
 * 
 */
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_chrom, __pyx_v_chrom) < 0) __PYX_ERR(0, 2018, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_window_size, __pyx_v_window_size) < 0) __PYX_ERR(0, 2018, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_window_offset, __pyx_v_window_offset) < 0) __PYX_ERR(0, 2018, __pyx_L1_error)
    __pyx_t_9 = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "pysamstats/opt.pyx":2020
 *         it = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 *                                chrom=chrom, window_size=window_size, window_offset=window_offset,
 *                                **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     return it
 */
    if (__Pyx_MergeKeywords(__pyx_t_9, __pyx_v_kwargs) < 0) __PYX_ERR(0, 2020, __pyx_L1_error)

    /* "pysamstats/opt.pyx":2018
 * 
 *     else:
 *         it = iter_binned_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,             # <<<<<<<<<<<<<<
 *                                chrom=chrom, window_size=window_size, window_offset=window_offset,
 *                                **kwargs)
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2018, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_it = __pyx_t_7;
    __pyx_t_7 = 0;
  }
  __pyx_L6:;

  /* "pysamstats/opt.pyx":2022
 *                                **kwargs)
 * 
 *     return it             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_it);
  __pyx_r = __pyx_v_it;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":1996
 * 
 * 
 * def iter_binned(stat, alignmentfile, fafile, chrom, window_size=300, window_offset=None,             # <<<<<<<<<<<<<<
 *                 **kwargs):
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("pysamstats.opt.iter_binned", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_its);
  __Pyx_XDECREF(__pyx_v_itc);
  __Pyx_XDECREF(__pyx_v_it);
  __Pyx_XDECREF(__pyx_v_alignmentfile);
  __Pyx_XDECREF(__pyx_v_fafile);
  __Pyx_XDECREF(__pyx_v_chrom);
  __Pyx_XDECREF(__pyx_v_window_offset);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10pysamstats_3opt_18generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "pysamstats/opt.pyx":2025
 * 
 * 
 * def iter_binned_chrom(BinnedStat stat, AlignmentFile alignmentfile, FastaFile fafile,             # <<<<<<<<<<<<<<
 *                       chrom, start, end, one_based, int window_size, int window_offset,
 *                       int min_mapq, int no_dup):
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_17iter_binned_chrom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_16iter_binned_chrom[] = "iter_binned_chrom(BinnedStat stat, AlignmentFile alignmentfile, FastaFile fafile, chrom, start, end, one_based, int window_size, int window_offset, int min_mapq, int no_dup)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_17iter_binned_chrom = {"iter_binned_chrom", (PyCFunction)__pyx_pw_10pysamstats_3opt_17iter_binned_chrom, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_16iter_binned_chrom};
static PyObject *__pyx_pw_10pysamstats_3opt_17iter_binned_chrom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_10pysamstats_3opt_BinnedStat *__pyx_v_stat = 0;
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile = 0;
  struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile = 0;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_end = 0;
  PyObject *__pyx_v_one_based = 0;
  int __pyx_v_window_size;
  int __pyx_v_window_offset;
  int __pyx_v_min_mapq;
  int __pyx_v_no_dup;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_binned_chrom (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stat,&__pyx_n_s_alignmentfile,&__pyx_n_s_fafile,&__pyx_n_s_chrom,&__pyx_n_s_start,&__pyx_n_s_end,&__pyx_n_s_one_based,&__pyx_n_s_window_size,&__pyx_n_s_window_offset,&__pyx_n_s_min_mapq,&__pyx_n_s_no_dup,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,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 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stat)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alignmentfile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 1); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fafile)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 2); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chrom)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 3); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 4); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 5); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_one_based)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 6); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 7); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case  8:
        if (likely((values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window_offset)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 8); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case  9:
        if (likely((values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_mapq)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 9); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
        case 10:
        if (likely((values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_no_dup)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, 10); __PYX_ERR(0, 2025, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "iter_binned_chrom") < 0)) __PYX_ERR(0, 2025, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 11) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
    }
    __pyx_v_stat = ((struct __pyx_obj_10pysamstats_3opt_BinnedStat *)values[0]);
    __pyx_v_alignmentfile = ((struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *)values[1]);
    __pyx_v_fafile = ((struct __pyx_obj_5pysam_9libcfaidx_FastaFile *)values[2]);
    __pyx_v_chrom = values[3];
    __pyx_v_start = values[4];
    __pyx_v_end = values[5];
    __pyx_v_one_based = values[6];
    __pyx_v_window_size = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_window_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2026, __pyx_L3_error)
    __pyx_v_window_offset = __Pyx_PyInt_As_int(values[8]); if (unlikely((__pyx_v_window_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2026, __pyx_L3_error)
    __pyx_v_min_mapq = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_min_mapq == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2027, __pyx_L3_error)
    __pyx_v_no_dup = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_no_dup == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2027, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("iter_binned_chrom", 1, 11, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2025, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.iter_binned_chrom", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_stat), __pyx_ptype_10pysamstats_3opt_BinnedStat, 1, "stat", 0))) __PYX_ERR(0, 2025, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alignmentfile), __pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile, 1, "alignmentfile", 0))) __PYX_ERR(0, 2025, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fafile), __pyx_ptype_5pysam_9libcfaidx_FastaFile, 1, "fafile", 0))) __PYX_ERR(0, 2025, __pyx_L1_error)
  __pyx_r = __pyx_pf_10pysamstats_3opt_16iter_binned_chrom(__pyx_self, __pyx_v_stat, __pyx_v_alignmentfile, __pyx_v_fafile, __pyx_v_chrom, __pyx_v_start, __pyx_v_end, __pyx_v_one_based, __pyx_v_window_size, __pyx_v_window_offset, __pyx_v_min_mapq, __pyx_v_no_dup);

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

static PyObject *__pyx_pf_10pysamstats_3opt_16iter_binned_chrom(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_10pysamstats_3opt_BinnedStat *__pyx_v_stat, struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *__pyx_v_fafile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_one_based, int __pyx_v_window_size, int __pyx_v_window_offset, int __pyx_v_min_mapq, int __pyx_v_no_dup) {
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("iter_binned_chrom", 0);
  __pyx_cur_scope = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *)__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom(__pyx_ptype_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2025, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_stat = __pyx_v_stat;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_stat);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_stat);
  __pyx_cur_scope->__pyx_v_alignmentfile = __pyx_v_alignmentfile;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile);
  __pyx_cur_scope->__pyx_v_fafile = __pyx_v_fafile;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_fafile);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_fafile);
  __pyx_cur_scope->__pyx_v_chrom = __pyx_v_chrom;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
  __pyx_cur_scope->__pyx_v_start = __pyx_v_start;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
  __pyx_cur_scope->__pyx_v_end = __pyx_v_end;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end);
  __pyx_cur_scope->__pyx_v_one_based = __pyx_v_one_based;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_one_based);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_one_based);
  __pyx_cur_scope->__pyx_v_window_size = __pyx_v_window_size;
  __pyx_cur_scope->__pyx_v_window_offset = __pyx_v_window_offset;
  __pyx_cur_scope->__pyx_v_min_mapq = __pyx_v_min_mapq;
  __pyx_cur_scope->__pyx_v_no_dup = __pyx_v_no_dup;
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10pysamstats_3opt_18generator2, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter_binned_chrom, __pyx_n_s_iter_binned_chrom, __pyx_n_s_pysamstats_opt); if (unlikely(!gen)) __PYX_ERR(0, 2025, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("pysamstats.opt.iter_binned_chrom", __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_10pysamstats_3opt_18generator2(__pyx_CoroutineObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *__pyx_cur_scope = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  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)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  bam1_t *__pyx_t_13;
  int __pyx_t_14;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L13_resume_from_yield;
    case 2: goto __pyx_L19_resume_from_yield;
    case 3: goto __pyx_L24_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2025, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2031
 *     # setup
 * 
 *     assert chrom is not None, 'chromosome is None'             # <<<<<<<<<<<<<<
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = (__pyx_cur_scope->__pyx_v_chrom != Py_None);
    if (unlikely(!(__pyx_t_1 != 0))) {
      PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_chromosome_is_None);
      __PYX_ERR(0, 2031, __pyx_L1_error)
    }
  }
  #endif

  /* "pysamstats/opt.pyx":2032
 * 
 *     assert chrom is not None, 'chromosome is None'
 *     start, end = normalise_coords(alignmentfile, chrom, start, end, one_based)             # <<<<<<<<<<<<<<
 * 
 *     cdef int rtid, rstart, rend, has_coord, bin_start, bin_end
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_normalise_coords); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2032, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[6] = {__pyx_t_4, ((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile), __pyx_cur_scope->__pyx_v_chrom, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_end, __pyx_cur_scope->__pyx_v_one_based};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2032, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[6] = {__pyx_t_4, ((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile), __pyx_cur_scope->__pyx_v_chrom, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_end, __pyx_cur_scope->__pyx_v_one_based};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 5+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2032, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(5+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2032, __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(((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile));
    __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile));
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_cur_scope->__pyx_v_chrom);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_cur_scope->__pyx_v_start);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end);
    PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_cur_scope->__pyx_v_end);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_one_based);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_one_based);
    PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_cur_scope->__pyx_v_one_based);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2032, __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;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    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_ERR(0, 2032, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2032, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2032, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2032, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_4), 2) < 0) __PYX_ERR(0, 2032, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2032, __pyx_L1_error)
    __pyx_L5_unpacking_done:;
  }
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_end);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_end, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "pysamstats/opt.pyx":2035
 * 
 *     cdef int rtid, rstart, rend, has_coord, bin_start, bin_end
 *     has_coord, rtid, rstart, rend = alignmentfile.parse_region(chrom, start, end, None)             # <<<<<<<<<<<<<<
 * 
 *     cdef IteratorRowRegion it
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile), __pyx_n_s_parse_region); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_chrom, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_end, Py_None};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2035, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_chrom, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_end, Py_None};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2035, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2035, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_cur_scope->__pyx_v_chrom);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_cur_scope->__pyx_v_start);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end);
    PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_5, __pyx_cur_scope->__pyx_v_end);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_4, 3+__pyx_t_5, Py_None);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2035, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    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_ERR(0, 2035, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_8);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_6,&__pyx_t_4,&__pyx_t_3,&__pyx_t_8};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2035, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_6,&__pyx_t_4,&__pyx_t_3,&__pyx_t_8};
    __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2035, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_9)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_9); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_9), 4) < 0) __PYX_ERR(0, 2035, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L7_unpacking_done;
    __pyx_L6_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2035, __pyx_L1_error)
    __pyx_L7_unpacking_done:;
  }
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2035, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2035, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2035, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2035, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_cur_scope->__pyx_v_has_coord = __pyx_t_5;
  __pyx_cur_scope->__pyx_v_rtid = __pyx_t_10;
  __pyx_cur_scope->__pyx_v_rstart = __pyx_t_11;
  __pyx_cur_scope->__pyx_v_rend = __pyx_t_12;

  /* "pysamstats/opt.pyx":2039
 *     cdef IteratorRowRegion it
 *     cdef bam1_t* b
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend, multiple_iterators=False)             # <<<<<<<<<<<<<<
 *     b = it.b
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_rtid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_rstart); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_rend); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile));
  __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_alignmentfile));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3);
  __pyx_t_2 = 0;
  __pyx_t_8 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_multiple_iterators, Py_False) < 0) __PYX_ERR(0, 2039, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowRegion), __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2039, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_cur_scope->__pyx_v_it = ((struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "pysamstats/opt.pyx":2040
 *     cdef bam1_t* b
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend, multiple_iterators=False)
 *     b = it.b             # <<<<<<<<<<<<<<
 * 
 *     # setup first bin
 */
  __pyx_t_13 = __pyx_cur_scope->__pyx_v_it->__pyx_base.b;
  __pyx_cur_scope->__pyx_v_b = __pyx_t_13;

  /* "pysamstats/opt.pyx":2043
 * 
 *     # setup first bin
 *     bin_start = rstart             # <<<<<<<<<<<<<<
 *     bin_end = bin_start + window_size
 * 
 */
  __pyx_cur_scope->__pyx_v_bin_start = __pyx_cur_scope->__pyx_v_rstart;

  /* "pysamstats/opt.pyx":2044
 *     # setup first bin
 *     bin_start = rstart
 *     bin_end = bin_start + window_size             # <<<<<<<<<<<<<<
 * 
 *     # iterate over reads
 */
  __pyx_cur_scope->__pyx_v_bin_end = (__pyx_cur_scope->__pyx_v_bin_start + __pyx_cur_scope->__pyx_v_window_size);

  /* "pysamstats/opt.pyx":2047
 * 
 *     # iterate over reads
 *     it.cnext()             # <<<<<<<<<<<<<<
 *     while it.retval > 0:
 *         while b.core.pos > bin_end:  # end of bin
 */
  ((struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion *)__pyx_cur_scope->__pyx_v_it->__pyx_vtab)->cnext(__pyx_cur_scope->__pyx_v_it);

  /* "pysamstats/opt.pyx":2048
 *     # iterate over reads
 *     it.cnext()
 *     while it.retval > 0:             # <<<<<<<<<<<<<<
 *         while b.core.pos > bin_end:  # end of bin
 * 
 */
  while (1) {
    __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_it->__pyx_base.retval > 0) != 0);
    if (!__pyx_t_1) break;

    /* "pysamstats/opt.pyx":2049
 *     it.cnext()
 *     while it.retval > 0:
 *         while b.core.pos > bin_end:  # end of bin             # <<<<<<<<<<<<<<
 * 
 *             # yield record for bin
 */
    while (1) {
      __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_b->core.pos > __pyx_cur_scope->__pyx_v_bin_end) != 0);
      if (!__pyx_t_1) break;

      /* "pysamstats/opt.pyx":2052
 * 
 *             # yield record for bin
 *             rec = stat.rec(chrom, bin_start, bin_end, fafile)             # <<<<<<<<<<<<<<
 *             pos = bin_start + window_offset
 *             if one_based:
 */
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_bin_start); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2052, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_bin_end); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2052, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = ((struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat *)__pyx_cur_scope->__pyx_v_stat->__pyx_vtab)->rec(__pyx_cur_scope->__pyx_v_stat, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_8, __pyx_t_3, __pyx_cur_scope->__pyx_v_fafile); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2052, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_rec);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_rec, ((PyObject*)__pyx_t_4));
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;

      /* "pysamstats/opt.pyx":2053
 *             # yield record for bin
 *             rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *             pos = bin_start + window_offset             # <<<<<<<<<<<<<<
 *             if one_based:
 *                 pos += 1
 */
      __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_cur_scope->__pyx_v_bin_start + __pyx_cur_scope->__pyx_v_window_offset)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2053, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_pos);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_pos, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;

      /* "pysamstats/opt.pyx":2054
 *             rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *             pos = bin_start + window_offset
 *             if one_based:             # <<<<<<<<<<<<<<
 *                 pos += 1
 *             rec['chrom'] = chrom
 */
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_one_based); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2054, __pyx_L1_error)
      if (__pyx_t_1) {

        /* "pysamstats/opt.pyx":2055
 *             pos = bin_start + window_offset
 *             if one_based:
 *                 pos += 1             # <<<<<<<<<<<<<<
 *             rec['chrom'] = chrom
 *             rec['pos'] = pos
 */
        __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_cur_scope->__pyx_v_pos, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2055, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_pos);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_pos, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "pysamstats/opt.pyx":2054
 *             rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *             pos = bin_start + window_offset
 *             if one_based:             # <<<<<<<<<<<<<<
 *                 pos += 1
 *             rec['chrom'] = chrom
 */
      }

      /* "pysamstats/opt.pyx":2056
 *             if one_based:
 *                 pos += 1
 *             rec['chrom'] = chrom             # <<<<<<<<<<<<<<
 *             rec['pos'] = pos
 *             yield rec
 */
      if (unlikely(__pyx_cur_scope->__pyx_v_rec == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 2056, __pyx_L1_error)
      }
      if (unlikely(PyDict_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_chrom, __pyx_cur_scope->__pyx_v_chrom) < 0)) __PYX_ERR(0, 2056, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2057
 *                 pos += 1
 *             rec['chrom'] = chrom
 *             rec['pos'] = pos             # <<<<<<<<<<<<<<
 *             yield rec
 * 
 */
      if (unlikely(__pyx_cur_scope->__pyx_v_rec == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 2057, __pyx_L1_error)
      }
      if (unlikely(PyDict_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_pos, __pyx_cur_scope->__pyx_v_pos) < 0)) __PYX_ERR(0, 2057, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2058
 *             rec['chrom'] = chrom
 *             rec['pos'] = pos
 *             yield rec             # <<<<<<<<<<<<<<
 * 
 *             # start new bin
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_rec);
      __pyx_r = __pyx_cur_scope->__pyx_v_rec;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L13_resume_from_yield:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2058, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2061
 * 
 *             # start new bin
 *             bin_start = bin_end             # <<<<<<<<<<<<<<
 *             bin_end = bin_start + window_size
 * 
 */
      __pyx_cur_scope->__pyx_v_bin_start = __pyx_cur_scope->__pyx_v_bin_end;

      /* "pysamstats/opt.pyx":2062
 *             # start new bin
 *             bin_start = bin_end
 *             bin_end = bin_start + window_size             # <<<<<<<<<<<<<<
 * 
 *         # process current read
 */
      __pyx_cur_scope->__pyx_v_bin_end = (__pyx_cur_scope->__pyx_v_bin_start + __pyx_cur_scope->__pyx_v_window_size);
    }

    /* "pysamstats/opt.pyx":2065
 * 
 *         # process current read
 *         if min_mapq > 0:             # <<<<<<<<<<<<<<
 *             if b.core.qual < min_mapq:
 *                 it.cnext()
 */
    __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_min_mapq > 0) != 0);
    if (__pyx_t_1) {

      /* "pysamstats/opt.pyx":2066
 *         # process current read
 *         if min_mapq > 0:
 *             if b.core.qual < min_mapq:             # <<<<<<<<<<<<<<
 *                 it.cnext()
 *                 continue
 */
      __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_b->core.qual < __pyx_cur_scope->__pyx_v_min_mapq) != 0);
      if (__pyx_t_1) {

        /* "pysamstats/opt.pyx":2067
 *         if min_mapq > 0:
 *             if b.core.qual < min_mapq:
 *                 it.cnext()             # <<<<<<<<<<<<<<
 *                 continue
 *         if no_dup:
 */
        ((struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion *)__pyx_cur_scope->__pyx_v_it->__pyx_vtab)->cnext(__pyx_cur_scope->__pyx_v_it);

        /* "pysamstats/opt.pyx":2068
 *             if b.core.qual < min_mapq:
 *                 it.cnext()
 *                 continue             # <<<<<<<<<<<<<<
 *         if no_dup:
 *             if <bint>(b.core.flag & BAM_FDUP):
 */
        goto __pyx_L8_continue;

        /* "pysamstats/opt.pyx":2066
 *         # process current read
 *         if min_mapq > 0:
 *             if b.core.qual < min_mapq:             # <<<<<<<<<<<<<<
 *                 it.cnext()
 *                 continue
 */
      }

      /* "pysamstats/opt.pyx":2065
 * 
 *         # process current read
 *         if min_mapq > 0:             # <<<<<<<<<<<<<<
 *             if b.core.qual < min_mapq:
 *                 it.cnext()
 */
    }

    /* "pysamstats/opt.pyx":2069
 *                 it.cnext()
 *                 continue
 *         if no_dup:             # <<<<<<<<<<<<<<
 *             if <bint>(b.core.flag & BAM_FDUP):
 *                 it.cnext()
 */
    __pyx_t_1 = (__pyx_cur_scope->__pyx_v_no_dup != 0);
    if (__pyx_t_1) {

      /* "pysamstats/opt.pyx":2070
 *                 continue
 *         if no_dup:
 *             if <bint>(b.core.flag & BAM_FDUP):             # <<<<<<<<<<<<<<
 *                 it.cnext()
 *                 continue
 */
      __pyx_t_1 = (((__pyx_cur_scope->__pyx_v_b->core.flag & 0x400) != 0) != 0);
      if (__pyx_t_1) {

        /* "pysamstats/opt.pyx":2071
 *         if no_dup:
 *             if <bint>(b.core.flag & BAM_FDUP):
 *                 it.cnext()             # <<<<<<<<<<<<<<
 *                 continue
 *         stat.recv(b)
 */
        ((struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion *)__pyx_cur_scope->__pyx_v_it->__pyx_vtab)->cnext(__pyx_cur_scope->__pyx_v_it);

        /* "pysamstats/opt.pyx":2072
 *             if <bint>(b.core.flag & BAM_FDUP):
 *                 it.cnext()
 *                 continue             # <<<<<<<<<<<<<<
 *         stat.recv(b)
 * 
 */
        goto __pyx_L8_continue;

        /* "pysamstats/opt.pyx":2070
 *                 continue
 *         if no_dup:
 *             if <bint>(b.core.flag & BAM_FDUP):             # <<<<<<<<<<<<<<
 *                 it.cnext()
 *                 continue
 */
      }

      /* "pysamstats/opt.pyx":2069
 *                 it.cnext()
 *                 continue
 *         if no_dup:             # <<<<<<<<<<<<<<
 *             if <bint>(b.core.flag & BAM_FDUP):
 *                 it.cnext()
 */
    }

    /* "pysamstats/opt.pyx":2073
 *                 it.cnext()
 *                 continue
 *         stat.recv(b)             # <<<<<<<<<<<<<<
 * 
 *         # move iterator on
 */
    ((struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat *)__pyx_cur_scope->__pyx_v_stat->__pyx_vtab)->recv(__pyx_cur_scope->__pyx_v_stat, __pyx_cur_scope->__pyx_v_b);

    /* "pysamstats/opt.pyx":2076
 * 
 *         # move iterator on
 *         it.cnext()             # <<<<<<<<<<<<<<
 * 
 *     # deal with last non-empty bin
 */
    ((struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion *)__pyx_cur_scope->__pyx_v_it->__pyx_vtab)->cnext(__pyx_cur_scope->__pyx_v_it);
    __pyx_L8_continue:;
  }

  /* "pysamstats/opt.pyx":2079
 * 
 *     # deal with last non-empty bin
 *     rec = stat.rec(chrom, bin_start, bin_end, fafile)             # <<<<<<<<<<<<<<
 *     pos = bin_start + window_offset
 *     if one_based:
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_bin_start); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2079, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_bin_end); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2079, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = ((struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat *)__pyx_cur_scope->__pyx_v_stat->__pyx_vtab)->rec(__pyx_cur_scope->__pyx_v_stat, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_4, __pyx_t_3, __pyx_cur_scope->__pyx_v_fafile); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2079, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_rec);
  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_rec, ((PyObject*)__pyx_t_8));
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "pysamstats/opt.pyx":2080
 *     # deal with last non-empty bin
 *     rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *     pos = bin_start + window_offset             # <<<<<<<<<<<<<<
 *     if one_based:
 *         pos += 1
 */
  __pyx_t_8 = __Pyx_PyInt_From_int((__pyx_cur_scope->__pyx_v_bin_start + __pyx_cur_scope->__pyx_v_window_offset)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_pos);
  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_pos, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;

  /* "pysamstats/opt.pyx":2081
 *     rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *     pos = bin_start + window_offset
 *     if one_based:             # <<<<<<<<<<<<<<
 *         pos += 1
 *     rec['chrom'] = chrom
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_one_based); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 2081, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":2082
 *     pos = bin_start + window_offset
 *     if one_based:
 *         pos += 1             # <<<<<<<<<<<<<<
 *     rec['chrom'] = chrom
 *     rec['pos'] = pos
 */
    __pyx_t_8 = __Pyx_PyInt_AddObjC(__pyx_cur_scope->__pyx_v_pos, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2082, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_pos);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_pos, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_8 = 0;

    /* "pysamstats/opt.pyx":2081
 *     rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *     pos = bin_start + window_offset
 *     if one_based:             # <<<<<<<<<<<<<<
 *         pos += 1
 *     rec['chrom'] = chrom
 */
  }

  /* "pysamstats/opt.pyx":2083
 *     if one_based:
 *         pos += 1
 *     rec['chrom'] = chrom             # <<<<<<<<<<<<<<
 *     rec['pos'] = pos
 *     yield rec
 */
  if (unlikely(__pyx_cur_scope->__pyx_v_rec == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 2083, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_chrom, __pyx_cur_scope->__pyx_v_chrom) < 0)) __PYX_ERR(0, 2083, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2084
 *         pos += 1
 *     rec['chrom'] = chrom
 *     rec['pos'] = pos             # <<<<<<<<<<<<<<
 *     yield rec
 * 
 */
  if (unlikely(__pyx_cur_scope->__pyx_v_rec == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 2084, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_pos, __pyx_cur_scope->__pyx_v_pos) < 0)) __PYX_ERR(0, 2084, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2085
 *     rec['chrom'] = chrom
 *     rec['pos'] = pos
 *     yield rec             # <<<<<<<<<<<<<<
 * 
 *     # deal with empty bins up to explicit end
 */
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_rec);
  __pyx_r = __pyx_cur_scope->__pyx_v_rec;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  /* return from generator, yielding value */
  __pyx_generator->resume_label = 2;
  return __pyx_r;
  __pyx_L19_resume_from_yield:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2085, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2088
 * 
 *     # deal with empty bins up to explicit end
 *     if end is not None:             # <<<<<<<<<<<<<<
 *         while bin_end < end:
 *             # start new bin
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_end != Py_None);
  __pyx_t_14 = (__pyx_t_1 != 0);
  if (__pyx_t_14) {

    /* "pysamstats/opt.pyx":2089
 *     # deal with empty bins up to explicit end
 *     if end is not None:
 *         while bin_end < end:             # <<<<<<<<<<<<<<
 *             # start new bin
 *             bin_start = bin_end
 */
    while (1) {
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_bin_end); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2089, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_8, __pyx_cur_scope->__pyx_v_end, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2089, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 2089, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!__pyx_t_14) break;

      /* "pysamstats/opt.pyx":2091
 *         while bin_end < end:
 *             # start new bin
 *             bin_start = bin_end             # <<<<<<<<<<<<<<
 *             bin_end = bin_start + window_size
 * 
 */
      __pyx_cur_scope->__pyx_v_bin_start = __pyx_cur_scope->__pyx_v_bin_end;

      /* "pysamstats/opt.pyx":2092
 *             # start new bin
 *             bin_start = bin_end
 *             bin_end = bin_start + window_size             # <<<<<<<<<<<<<<
 * 
 *             # yield record
 */
      __pyx_cur_scope->__pyx_v_bin_end = (__pyx_cur_scope->__pyx_v_bin_start + __pyx_cur_scope->__pyx_v_window_size);

      /* "pysamstats/opt.pyx":2095
 * 
 *             # yield record
 *             rec = stat.rec(chrom, bin_start, bin_end, fafile)             # <<<<<<<<<<<<<<
 *             pos = bin_start + window_offset
 *             if one_based:
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_bin_start); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2095, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_bin_end); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2095, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = ((struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat *)__pyx_cur_scope->__pyx_v_stat->__pyx_vtab)->rec(__pyx_cur_scope->__pyx_v_stat, __pyx_cur_scope->__pyx_v_chrom, __pyx_t_3, __pyx_t_8, __pyx_cur_scope->__pyx_v_fafile); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2095, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_rec);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_rec, ((PyObject*)__pyx_t_4));
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;

      /* "pysamstats/opt.pyx":2096
 *             # yield record
 *             rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *             pos = bin_start + window_offset             # <<<<<<<<<<<<<<
 *             if one_based:
 *                 pos += 1
 */
      __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_cur_scope->__pyx_v_bin_start + __pyx_cur_scope->__pyx_v_window_offset)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2096, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_pos);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_pos, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;

      /* "pysamstats/opt.pyx":2097
 *             rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *             pos = bin_start + window_offset
 *             if one_based:             # <<<<<<<<<<<<<<
 *                 pos += 1
 *             rec['chrom'] = chrom
 */
      __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_one_based); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 2097, __pyx_L1_error)
      if (__pyx_t_14) {

        /* "pysamstats/opt.pyx":2098
 *             pos = bin_start + window_offset
 *             if one_based:
 *                 pos += 1             # <<<<<<<<<<<<<<
 *             rec['chrom'] = chrom
 *             rec['pos'] = pos
 */
        __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_cur_scope->__pyx_v_pos, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2098, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_pos);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_pos, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "pysamstats/opt.pyx":2097
 *             rec = stat.rec(chrom, bin_start, bin_end, fafile)
 *             pos = bin_start + window_offset
 *             if one_based:             # <<<<<<<<<<<<<<
 *                 pos += 1
 *             rec['chrom'] = chrom
 */
      }

      /* "pysamstats/opt.pyx":2099
 *             if one_based:
 *                 pos += 1
 *             rec['chrom'] = chrom             # <<<<<<<<<<<<<<
 *             rec['pos'] = pos
 *             yield rec
 */
      if (unlikely(__pyx_cur_scope->__pyx_v_rec == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 2099, __pyx_L1_error)
      }
      if (unlikely(PyDict_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_chrom, __pyx_cur_scope->__pyx_v_chrom) < 0)) __PYX_ERR(0, 2099, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2100
 *                 pos += 1
 *             rec['chrom'] = chrom
 *             rec['pos'] = pos             # <<<<<<<<<<<<<<
 *             yield rec
 * 
 */
      if (unlikely(__pyx_cur_scope->__pyx_v_rec == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 2100, __pyx_L1_error)
      }
      if (unlikely(PyDict_SetItem(__pyx_cur_scope->__pyx_v_rec, __pyx_n_s_pos, __pyx_cur_scope->__pyx_v_pos) < 0)) __PYX_ERR(0, 2100, __pyx_L1_error)

      /* "pysamstats/opt.pyx":2101
 *             rec['chrom'] = chrom
 *             rec['pos'] = pos
 *             yield rec             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_rec);
      __pyx_r = __pyx_cur_scope->__pyx_v_rec;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L24_resume_from_yield:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2101, __pyx_L1_error)
    }

    /* "pysamstats/opt.pyx":2088
 * 
 *     # deal with empty bins up to explicit end
 *     if end is not None:             # <<<<<<<<<<<<<<
 *         while bin_end < end:
 *             # start new bin
 */
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "pysamstats/opt.pyx":2025
 * 
 * 
 * def iter_binned_chrom(BinnedStat stat, AlignmentFile alignmentfile, FastaFile fafile,             # <<<<<<<<<<<<<<
 *                       chrom, start, end, one_based, int window_size, int window_offset,
 *                       int min_mapq, int no_dup):
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("iter_binned_chrom", __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;
}

/* "pysamstats/opt.pyx":2104
 * 
 * 
 * def normalise_coords(AlignmentFile alignmentfile, chrom, start, end, one_based):             # <<<<<<<<<<<<<<
 *     """Convert to zero-based coordinates and deal with unspecified start
 *     and/or end.
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_20normalise_coords(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_19normalise_coords[] = "normalise_coords(AlignmentFile alignmentfile, chrom, start, end, one_based)\nConvert to zero-based coordinates and deal with unspecified start\n    and/or end.\n\n    ";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_20normalise_coords = {"normalise_coords", (PyCFunction)__pyx_pw_10pysamstats_3opt_20normalise_coords, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_19normalise_coords};
static PyObject *__pyx_pw_10pysamstats_3opt_20normalise_coords(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile = 0;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_end = 0;
  PyObject *__pyx_v_one_based = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("normalise_coords (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alignmentfile,&__pyx_n_s_chrom,&__pyx_n_s_start,&__pyx_n_s_end,&__pyx_n_s_one_based,0};
    PyObject* values[5] = {0,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  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_alignmentfile)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chrom)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("normalise_coords", 1, 5, 5, 1); __PYX_ERR(0, 2104, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("normalise_coords", 1, 5, 5, 2); __PYX_ERR(0, 2104, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("normalise_coords", 1, 5, 5, 3); __PYX_ERR(0, 2104, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_one_based)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("normalise_coords", 1, 5, 5, 4); __PYX_ERR(0, 2104, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "normalise_coords") < 0)) __PYX_ERR(0, 2104, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_alignmentfile = ((struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *)values[0]);
    __pyx_v_chrom = values[1];
    __pyx_v_start = values[2];
    __pyx_v_end = values[3];
    __pyx_v_one_based = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("normalise_coords", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2104, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.normalise_coords", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alignmentfile), __pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile, 1, "alignmentfile", 0))) __PYX_ERR(0, 2104, __pyx_L1_error)
  __pyx_r = __pyx_pf_10pysamstats_3opt_19normalise_coords(__pyx_self, __pyx_v_alignmentfile, __pyx_v_chrom, __pyx_v_start, __pyx_v_end, __pyx_v_one_based);

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

static PyObject *__pyx_pf_10pysamstats_3opt_19normalise_coords(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_one_based) {
  PyObject *__pyx_v_chrlen = NULL;
  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;
  __Pyx_RefNannySetupContext("normalise_coords", 0);
  __Pyx_INCREF(__pyx_v_start);
  __Pyx_INCREF(__pyx_v_end);

  /* "pysamstats/opt.pyx":2110
 *     """
 * 
 *     if chrom is None:             # <<<<<<<<<<<<<<
 *         return None, None
 * 
 */
  __pyx_t_1 = (__pyx_v_chrom == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "pysamstats/opt.pyx":2111
 * 
 *     if chrom is None:
 *         return None, None             # <<<<<<<<<<<<<<
 * 
 *     else:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_tuple__4);
    __pyx_r = __pyx_tuple__4;
    goto __pyx_L0;

    /* "pysamstats/opt.pyx":2110
 *     """
 * 
 *     if chrom is None:             # <<<<<<<<<<<<<<
 *         return None, None
 * 
 */
  }

  /* "pysamstats/opt.pyx":2114
 * 
 *     else:
 *         assert chrom in alignmentfile.references, \             # <<<<<<<<<<<<<<
 *             'chromosome not in SAM references: %s' % chrom
 * 
 */
  /*else*/ {
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!Py_OptimizeFlag)) {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_alignmentfile), __pyx_n_s_references); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_chrom, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2114, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!(__pyx_t_2 != 0))) {

        /* "pysamstats/opt.pyx":2115
 *     else:
 *         assert chrom in alignmentfile.references, \
 *             'chromosome not in SAM references: %s' % chrom             # <<<<<<<<<<<<<<
 * 
 *         if one_based:
 */
        __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_chromosome_not_in_SAM_references, __pyx_v_chrom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2115, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        PyErr_SetObject(PyExc_AssertionError, __pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(0, 2114, __pyx_L1_error)
      }
    }
    #endif

    /* "pysamstats/opt.pyx":2117
 *             'chromosome not in SAM references: %s' % chrom
 * 
 *         if one_based:             # <<<<<<<<<<<<<<
 *             start = start - 1 if start is not None else None
 *             end = end - 1 if end is not None else None
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_one_based); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2117, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":2118
 * 
 *         if one_based:
 *             start = start - 1 if start is not None else None             # <<<<<<<<<<<<<<
 *             end = end - 1 if end is not None else None
 * 
 */
      __pyx_t_2 = (__pyx_v_start != Py_None);
      if ((__pyx_t_2 != 0)) {
        __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_start, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2118, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __pyx_t_4;
        __pyx_t_4 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __Pyx_DECREF_SET(__pyx_v_start, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysamstats/opt.pyx":2119
 *         if one_based:
 *             start = start - 1 if start is not None else None
 *             end = end - 1 if end is not None else None             # <<<<<<<<<<<<<<
 * 
 *         chrlen = alignmentfile.lengths[alignmentfile.references.index(chrom)]
 */
      __pyx_t_2 = (__pyx_v_end != Py_None);
      if ((__pyx_t_2 != 0)) {
        __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_end, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2119, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __pyx_t_4;
        __pyx_t_4 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_3 = Py_None;
      }
      __Pyx_DECREF_SET(__pyx_v_end, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "pysamstats/opt.pyx":2117
 *             'chromosome not in SAM references: %s' % chrom
 * 
 *         if one_based:             # <<<<<<<<<<<<<<
 *             start = start - 1 if start is not None else None
 *             end = end - 1 if end is not None else None
 */
    }

    /* "pysamstats/opt.pyx":2121
 *             end = end - 1 if end is not None else None
 * 
 *         chrlen = alignmentfile.lengths[alignmentfile.references.index(chrom)]             # <<<<<<<<<<<<<<
 *         if start is None:
 *             start = 0
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_alignmentfile), __pyx_n_s_lengths); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_alignmentfile), __pyx_n_s_references); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_chrom); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_chrom};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2121, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_v_chrom};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2121, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else
      #endif
      {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2121, __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_INCREF(__pyx_v_chrom);
        __Pyx_GIVEREF(__pyx_v_chrom);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_chrom);
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_GetItem(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_chrlen = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "pysamstats/opt.pyx":2122
 * 
 *         chrlen = alignmentfile.lengths[alignmentfile.references.index(chrom)]
 *         if start is None:             # <<<<<<<<<<<<<<
 *             start = 0
 *         if end is None:
 */
    __pyx_t_2 = (__pyx_v_start == Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "pysamstats/opt.pyx":2123
 *         chrlen = alignmentfile.lengths[alignmentfile.references.index(chrom)]
 *         if start is None:
 *             start = 0             # <<<<<<<<<<<<<<
 *         if end is None:
 *             end = chrlen
 */
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_DECREF_SET(__pyx_v_start, __pyx_int_0);

      /* "pysamstats/opt.pyx":2122
 * 
 *         chrlen = alignmentfile.lengths[alignmentfile.references.index(chrom)]
 *         if start is None:             # <<<<<<<<<<<<<<
 *             start = 0
 *         if end is None:
 */
    }

    /* "pysamstats/opt.pyx":2124
 *         if start is None:
 *             start = 0
 *         if end is None:             # <<<<<<<<<<<<<<
 *             end = chrlen
 *         if end > chrlen:
 */
    __pyx_t_1 = (__pyx_v_end == Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":2125
 *             start = 0
 *         if end is None:
 *             end = chrlen             # <<<<<<<<<<<<<<
 *         if end > chrlen:
 *             end = chrlen
 */
      __Pyx_INCREF(__pyx_v_chrlen);
      __Pyx_DECREF_SET(__pyx_v_end, __pyx_v_chrlen);

      /* "pysamstats/opt.pyx":2124
 *         if start is None:
 *             start = 0
 *         if end is None:             # <<<<<<<<<<<<<<
 *             end = chrlen
 *         if end > chrlen:
 */
    }

    /* "pysamstats/opt.pyx":2126
 *         if end is None:
 *             end = chrlen
 *         if end > chrlen:             # <<<<<<<<<<<<<<
 *             end = chrlen
 * 
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_end, __pyx_v_chrlen, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2126, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 2126, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {

      /* "pysamstats/opt.pyx":2127
 *             end = chrlen
 *         if end > chrlen:
 *             end = chrlen             # <<<<<<<<<<<<<<
 * 
 *         return start, end
 */
      __Pyx_INCREF(__pyx_v_chrlen);
      __Pyx_DECREF_SET(__pyx_v_end, __pyx_v_chrlen);

      /* "pysamstats/opt.pyx":2126
 *         if end is None:
 *             end = chrlen
 *         if end > chrlen:             # <<<<<<<<<<<<<<
 *             end = chrlen
 * 
 */
    }

    /* "pysamstats/opt.pyx":2129
 *             end = chrlen
 * 
 *         return start, end             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_start);
    __Pyx_GIVEREF(__pyx_v_start);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_start);
    __Pyx_INCREF(__pyx_v_end);
    __Pyx_GIVEREF(__pyx_v_end);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_end);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }

  /* "pysamstats/opt.pyx":2104
 * 
 * 
 * def normalise_coords(AlignmentFile alignmentfile, chrom, start, end, one_based):             # <<<<<<<<<<<<<<
 *     """Convert to zero-based coordinates and deal with unspecified start
 *     and/or end.
 */

  /* 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("pysamstats.opt.normalise_coords", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_chrlen);
  __Pyx_XDECREF(__pyx_v_start);
  __Pyx_XDECREF(__pyx_v_end);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":2132
 * 
 * 
 * cdef inline bint is_softclipped(bam1_t* aln):             # <<<<<<<<<<<<<<
 *     cdef int k
 *     cigar_p = pysam_bam_get_cigar(aln)
 */

static CYTHON_INLINE int __pyx_f_10pysamstats_3opt_is_softclipped(bam1_t *__pyx_v_aln) {
  int __pyx_v_k;
  uint32_t *__pyx_v_cigar_p;
  long __pyx_v_op;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  uint32_t __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("is_softclipped", 0);

  /* "pysamstats/opt.pyx":2134
 * cdef inline bint is_softclipped(bam1_t* aln):
 *     cdef int k
 *     cigar_p = pysam_bam_get_cigar(aln)             # <<<<<<<<<<<<<<
 *     for k in range(aln.core.n_cigar):
 *         op = cigar_p[k] & BAM_CIGAR_MASK
 */
  __pyx_v_cigar_p = pysam_bam_get_cigar(__pyx_v_aln);

  /* "pysamstats/opt.pyx":2135
 *     cdef int k
 *     cigar_p = pysam_bam_get_cigar(aln)
 *     for k in range(aln.core.n_cigar):             # <<<<<<<<<<<<<<
 *         op = cigar_p[k] & BAM_CIGAR_MASK
 *         if op == BAM_CSOFT_CLIP:
 */
  __pyx_t_1 = __pyx_v_aln->core.n_cigar;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_k = __pyx_t_2;

    /* "pysamstats/opt.pyx":2136
 *     cigar_p = pysam_bam_get_cigar(aln)
 *     for k in range(aln.core.n_cigar):
 *         op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
 *         if op == BAM_CSOFT_CLIP:
 *             return 1
 */
    __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);

    /* "pysamstats/opt.pyx":2137
 *     for k in range(aln.core.n_cigar):
 *         op = cigar_p[k] & BAM_CIGAR_MASK
 *         if op == BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
 *             return 1
 *     return 0
 */
    __pyx_t_3 = ((__pyx_v_op == 4) != 0);
    if (__pyx_t_3) {

      /* "pysamstats/opt.pyx":2138
 *         op = cigar_p[k] & BAM_CIGAR_MASK
 *         if op == BAM_CSOFT_CLIP:
 *             return 1             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "pysamstats/opt.pyx":2137
 *     for k in range(aln.core.n_cigar):
 *         op = cigar_p[k] & BAM_CIGAR_MASK
 *         if op == BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
 *             return 1
 *     return 0
 */
    }
  }

  /* "pysamstats/opt.pyx":2139
 *         if op == BAM_CSOFT_CLIP:
 *             return 1
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":2132
 * 
 * 
 * cdef inline bint is_softclipped(bam1_t* aln):             # <<<<<<<<<<<<<<
 *     cdef int k
 *     cigar_p = pysam_bam_get_cigar(aln)
 */

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

/* "pysamstats/opt.pyx":2142
 * 
 * 
 * cdef inline object get_seq_base(bam1_t *src, uint32_t k):             # <<<<<<<<<<<<<<
 *     cdef uint8_t* p
 *     cdef char* s
 */

static CYTHON_INLINE PyObject *__pyx_f_10pysamstats_3opt_get_seq_base(bam1_t *__pyx_v_src, uint32_t __pyx_v_k) {
  uint8_t *__pyx_v_p;
  char *__pyx_v_s;
  PyObject *__pyx_v_seq = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  char *__pyx_t_3;
  __Pyx_RefNannySetupContext("get_seq_base", 0);

  /* "pysamstats/opt.pyx":2146
 *     cdef char* s
 * 
 *     if not src.core.l_qseq:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_src->core.l_qseq != 0)) != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":2147
 * 
 *     if not src.core.l_qseq:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     seq = PyBytes_FromStringAndSize(NULL, 1)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;

    /* "pysamstats/opt.pyx":2146
 *     cdef char* s
 * 
 *     if not src.core.l_qseq:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  }

  /* "pysamstats/opt.pyx":2149
 *         return None
 * 
 *     seq = PyBytes_FromStringAndSize(NULL, 1)             # <<<<<<<<<<<<<<
 *     s   = <char*>seq
 *     p   = pysam_bam_get_seq(src)
 */
  __pyx_t_2 = PyBytes_FromStringAndSize(NULL, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_seq = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":2150
 * 
 *     seq = PyBytes_FromStringAndSize(NULL, 1)
 *     s   = <char*>seq             # <<<<<<<<<<<<<<
 *     p   = pysam_bam_get_seq(src)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_v_seq); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) __PYX_ERR(0, 2150, __pyx_L1_error)
  __pyx_v_s = ((char *)__pyx_t_3);

  /* "pysamstats/opt.pyx":2151
 *     seq = PyBytes_FromStringAndSize(NULL, 1)
 *     s   = <char*>seq
 *     p   = pysam_bam_get_seq(src)             # <<<<<<<<<<<<<<
 * 
 *     s[0] = bam_nt16_rev_table[p[k//2] >> 4 * (1 - k%2) & 0xf]
 */
  __pyx_v_p = pysam_bam_get_seq(__pyx_v_src);

  /* "pysamstats/opt.pyx":2153
 *     p   = pysam_bam_get_seq(src)
 * 
 *     s[0] = bam_nt16_rev_table[p[k//2] >> 4 * (1 - k%2) & 0xf]             # <<<<<<<<<<<<<<
 * 
 *     return seq
 */
  (__pyx_v_s[0]) = (__pyx_v_10pysamstats_3opt_bam_nt16_rev_table[(((__pyx_v_p[__Pyx_div_long(__pyx_v_k, 2)]) >> (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2)))) & 0xf)]);

  /* "pysamstats/opt.pyx":2155
 *     s[0] = bam_nt16_rev_table[p[k//2] >> 4 * (1 - k%2) & 0xf]
 * 
 *     return seq             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_seq);
  __pyx_r = __pyx_v_seq;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":2142
 * 
 * 
 * cdef inline object get_seq_base(bam1_t *src, uint32_t k):             # <<<<<<<<<<<<<<
 *     cdef uint8_t* p
 *     cdef char* s
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("pysamstats.opt.get_seq_base", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_seq);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":2158
 * 
 * 
 * def rootmean(uint64_t sqsum, int count):             # <<<<<<<<<<<<<<
 *     if count > 0:
 *         return int(round(sqrt(sqsum / count)))
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_22rootmean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_21rootmean[] = "rootmean(uint64_t sqsum, int count)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_22rootmean = {"rootmean", (PyCFunction)__pyx_pw_10pysamstats_3opt_22rootmean, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_21rootmean};
static PyObject *__pyx_pw_10pysamstats_3opt_22rootmean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  uint64_t __pyx_v_sqsum;
  int __pyx_v_count;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("rootmean (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sqsum,&__pyx_n_s_count,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_sqsum)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_count)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("rootmean", 1, 2, 2, 1); __PYX_ERR(0, 2158, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rootmean") < 0)) __PYX_ERR(0, 2158, __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_sqsum = __Pyx_PyInt_As_uint64_t(values[0]); if (unlikely((__pyx_v_sqsum == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2158, __pyx_L3_error)
    __pyx_v_count = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_count == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2158, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("rootmean", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2158, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.rootmean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10pysamstats_3opt_21rootmean(__pyx_self, __pyx_v_sqsum, __pyx_v_count);

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

static PyObject *__pyx_pf_10pysamstats_3opt_21rootmean(CYTHON_UNUSED PyObject *__pyx_self, uint64_t __pyx_v_sqsum, int __pyx_v_count) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("rootmean", 0);

  /* "pysamstats/opt.pyx":2159
 * 
 * def rootmean(uint64_t sqsum, int count):
 *     if count > 0:             # <<<<<<<<<<<<<<
 *         return int(round(sqrt(sqsum / count)))
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_count > 0) != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":2160
 * def rootmean(uint64_t sqsum, int count):
 *     if count > 0:
 *         return int(round(sqrt(sqsum / count)))             # <<<<<<<<<<<<<<
 *     else:
 *         return 0
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_count == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 2160, __pyx_L1_error)
    }
    __pyx_t_2 = PyFloat_FromDouble(sqrt((((double)__pyx_v_sqsum) / ((double)__pyx_v_count)))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2160, __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_round, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2160, __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;

    /* "pysamstats/opt.pyx":2159
 * 
 * def rootmean(uint64_t sqsum, int count):
 *     if count > 0:             # <<<<<<<<<<<<<<
 *         return int(round(sqrt(sqsum / count)))
 *     else:
 */
  }

  /* "pysamstats/opt.pyx":2162
 *         return int(round(sqrt(sqsum / count)))
 *     else:
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_r = __pyx_int_0;
    goto __pyx_L0;
  }

  /* "pysamstats/opt.pyx":2158
 * 
 * 
 * def rootmean(uint64_t sqsum, int count):             # <<<<<<<<<<<<<<
 *     if count > 0:
 *         return int(round(sqrt(sqsum / count)))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysamstats.opt.rootmean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":2165
 * 
 * 
 * def mean(int64_t total, int count):             # <<<<<<<<<<<<<<
 *     if count > 0:
 *         return int(round(total / count))
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_24mean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_23mean[] = "mean(int64_t total, int count)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_24mean = {"mean", (PyCFunction)__pyx_pw_10pysamstats_3opt_24mean, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_23mean};
static PyObject *__pyx_pw_10pysamstats_3opt_24mean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int64_t __pyx_v_total;
  int __pyx_v_count;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("mean (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_total,&__pyx_n_s_count,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_total)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_count)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("mean", 1, 2, 2, 1); __PYX_ERR(0, 2165, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "mean") < 0)) __PYX_ERR(0, 2165, __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_total = __Pyx_PyInt_As_int64_t(values[0]); if (unlikely((__pyx_v_total == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 2165, __pyx_L3_error)
    __pyx_v_count = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_count == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 2165, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("mean", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2165, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10pysamstats_3opt_23mean(__pyx_self, __pyx_v_total, __pyx_v_count);

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

static PyObject *__pyx_pf_10pysamstats_3opt_23mean(CYTHON_UNUSED PyObject *__pyx_self, int64_t __pyx_v_total, int __pyx_v_count) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("mean", 0);

  /* "pysamstats/opt.pyx":2166
 * 
 * def mean(int64_t total, int count):
 *     if count > 0:             # <<<<<<<<<<<<<<
 *         return int(round(total / count))
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_count > 0) != 0);
  if (__pyx_t_1) {

    /* "pysamstats/opt.pyx":2167
 * def mean(int64_t total, int count):
 *     if count > 0:
 *         return int(round(total / count))             # <<<<<<<<<<<<<<
 *     else:
 *         return 0
 */
    __Pyx_XDECREF(__pyx_r);
    if (unlikely(__pyx_v_count == 0)) {
      PyErr_SetString(PyExc_ZeroDivisionError, "float division");
      __PYX_ERR(0, 2167, __pyx_L1_error)
    }
    __pyx_t_2 = PyFloat_FromDouble((((double)__pyx_v_total) / ((double)__pyx_v_count))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2167, __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_round, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2167, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2167, __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;

    /* "pysamstats/opt.pyx":2166
 * 
 * def mean(int64_t total, int count):
 *     if count > 0:             # <<<<<<<<<<<<<<
 *         return int(round(total / count))
 *     else:
 */
  }

  /* "pysamstats/opt.pyx":2169
 *         return int(round(total / count))
 *     else:
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_r = __pyx_int_0;
    goto __pyx_L0;
  }

  /* "pysamstats/opt.pyx":2165
 * 
 * 
 * def mean(int64_t total, int count):             # <<<<<<<<<<<<<<
 *     if count > 0:
 *         return int(round(total / count))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("pysamstats.opt.mean", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "pysamstats/opt.pyx":2175
 * 
 * 
 * def count_reads(AlignmentFile alignmentfile, chrom=None, start=None, end=None):             # <<<<<<<<<<<<<<
 *     cdef IteratorRowRegion it
 *     cdef int n = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_10pysamstats_3opt_26count_reads(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_10pysamstats_3opt_25count_reads[] = "count_reads(AlignmentFile alignmentfile, chrom=None, start=None, end=None)";
static PyMethodDef __pyx_mdef_10pysamstats_3opt_26count_reads = {"count_reads", (PyCFunction)__pyx_pw_10pysamstats_3opt_26count_reads, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10pysamstats_3opt_25count_reads};
static PyObject *__pyx_pw_10pysamstats_3opt_26count_reads(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile = 0;
  PyObject *__pyx_v_chrom = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_end = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("count_reads (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_alignmentfile,&__pyx_n_s_chrom,&__pyx_n_s_start,&__pyx_n_s_end,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((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  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_alignmentfile)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_chrom);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_start);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_end);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "count_reads") < 0)) __PYX_ERR(0, 2175, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_alignmentfile = ((struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *)values[0]);
    __pyx_v_chrom = values[1];
    __pyx_v_start = values[2];
    __pyx_v_end = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("count_reads", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 2175, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("pysamstats.opt.count_reads", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alignmentfile), __pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile, 1, "alignmentfile", 0))) __PYX_ERR(0, 2175, __pyx_L1_error)
  __pyx_r = __pyx_pf_10pysamstats_3opt_25count_reads(__pyx_self, __pyx_v_alignmentfile, __pyx_v_chrom, __pyx_v_start, __pyx_v_end);

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

static PyObject *__pyx_pf_10pysamstats_3opt_25count_reads(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *__pyx_v_alignmentfile, PyObject *__pyx_v_chrom, PyObject *__pyx_v_start, PyObject *__pyx_v_end) {
  struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *__pyx_v_it = 0;
  int __pyx_v_n;
  CYTHON_UNUSED PyObject *__pyx_v_has_coord = NULL;
  PyObject *__pyx_v_rtid = NULL;
  PyObject *__pyx_v_rstart = NULL;
  PyObject *__pyx_v_rend = 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;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("count_reads", 0);

  /* "pysamstats/opt.pyx":2177
 * def count_reads(AlignmentFile alignmentfile, chrom=None, start=None, end=None):
 *     cdef IteratorRowRegion it
 *     cdef int n = 0             # <<<<<<<<<<<<<<
 *     has_coord, rtid, rstart, rend = alignmentfile.parse_region(chrom, start,
 *                                                                end, None)
 */
  __pyx_v_n = 0;

  /* "pysamstats/opt.pyx":2178
 *     cdef IteratorRowRegion it
 *     cdef int n = 0
 *     has_coord, rtid, rstart, rend = alignmentfile.parse_region(chrom, start,             # <<<<<<<<<<<<<<
 *                                                                end, None)
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_alignmentfile), __pyx_n_s_parse_region); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "pysamstats/opt.pyx":2179
 *     cdef int n = 0
 *     has_coord, rtid, rstart, rend = alignmentfile.parse_region(chrom, start,
 *                                                                end, None)             # <<<<<<<<<<<<<<
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend,
 *                            multiple_iterators=False)
 */
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && 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);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_chrom, __pyx_v_start, __pyx_v_end, Py_None};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2178, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_chrom, __pyx_v_start, __pyx_v_end, Py_None};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2178, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2178, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_chrom);
    __Pyx_GIVEREF(__pyx_v_chrom);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_chrom);
    __Pyx_INCREF(__pyx_v_start);
    __Pyx_GIVEREF(__pyx_v_start);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_start);
    __Pyx_INCREF(__pyx_v_end);
    __Pyx_GIVEREF(__pyx_v_end);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_end);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, Py_None);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2178, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if !CYTHON_COMPILING_IN_PYPY
    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_ERR(0, 2178, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_6);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_5,&__pyx_t_3,&__pyx_t_6};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 2178, __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_2,&__pyx_t_5,&__pyx_t_3,&__pyx_t_6};
    __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2178, __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;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_8(__pyx_t_7); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 4) < 0) __PYX_ERR(0, 2178, __pyx_L1_error)
    __pyx_t_8 = NULL;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 2178, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }

  /* "pysamstats/opt.pyx":2178
 *     cdef IteratorRowRegion it
 *     cdef int n = 0
 *     has_coord, rtid, rstart, rend = alignmentfile.parse_region(chrom, start,             # <<<<<<<<<<<<<<
 *                                                                end, None)
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend,
 */
  __pyx_v_has_coord = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_rtid = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_rstart = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_v_rend = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "pysamstats/opt.pyx":2180
 *     has_coord, rtid, rstart, rend = alignmentfile.parse_region(chrom, start,
 *                                                                end, None)
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend,             # <<<<<<<<<<<<<<
 *                            multiple_iterators=False)
 *     while True:
 */
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_alignmentfile));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_alignmentfile));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_alignmentfile));
  __Pyx_INCREF(__pyx_v_rtid);
  __Pyx_GIVEREF(__pyx_v_rtid);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_rtid);
  __Pyx_INCREF(__pyx_v_rstart);
  __Pyx_GIVEREF(__pyx_v_rstart);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_rstart);
  __Pyx_INCREF(__pyx_v_rend);
  __Pyx_GIVEREF(__pyx_v_rend);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_rend);

  /* "pysamstats/opt.pyx":2181
 *                                                                end, None)
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend,
 *                            multiple_iterators=False)             # <<<<<<<<<<<<<<
 *     while True:
 *         it.cnext()
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_multiple_iterators, Py_False) < 0) __PYX_ERR(0, 2181, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2180
 *     has_coord, rtid, rstart, rend = alignmentfile.parse_region(chrom, start,
 *                                                                end, None)
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend,             # <<<<<<<<<<<<<<
 *                            multiple_iterators=False)
 *     while True:
 */
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowRegion), __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_it = ((struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "pysamstats/opt.pyx":2182
 *     it = IteratorRowRegion(alignmentfile, rtid, rstart, rend,
 *                            multiple_iterators=False)
 *     while True:             # <<<<<<<<<<<<<<
 *         it.cnext()
 *         if it.retval > 0:
 */
  while (1) {

    /* "pysamstats/opt.pyx":2183
 *                            multiple_iterators=False)
 *     while True:
 *         it.cnext()             # <<<<<<<<<<<<<<
 *         if it.retval > 0:
 *             n += 1
 */
    ((struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion *)__pyx_v_it->__pyx_vtab)->cnext(__pyx_v_it);

    /* "pysamstats/opt.pyx":2184
 *     while True:
 *         it.cnext()
 *         if it.retval > 0:             # <<<<<<<<<<<<<<
 *             n += 1
 *         else:
 */
    __pyx_t_9 = ((__pyx_v_it->__pyx_base.retval > 0) != 0);
    if (__pyx_t_9) {

      /* "pysamstats/opt.pyx":2185
 *         it.cnext()
 *         if it.retval > 0:
 *             n += 1             # <<<<<<<<<<<<<<
 *         else:
 *             break
 */
      __pyx_v_n = (__pyx_v_n + 1);

      /* "pysamstats/opt.pyx":2184
 *     while True:
 *         it.cnext()
 *         if it.retval > 0:             # <<<<<<<<<<<<<<
 *             n += 1
 *         else:
 */
      goto __pyx_L7;
    }

    /* "pysamstats/opt.pyx":2187
 *             n += 1
 *         else:
 *             break             # <<<<<<<<<<<<<<
 *     return n
 */
    /*else*/ {
      goto __pyx_L6_break;
    }
    __pyx_L7:;
  }
  __pyx_L6_break:;

  /* "pysamstats/opt.pyx":2188
 *         else:
 *             break
 *     return n             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "pysamstats/opt.pyx":2175
 * 
 * 
 * def count_reads(AlignmentFile alignmentfile, chrom=None, start=None, end=None):             # <<<<<<<<<<<<<<
 *     cdef IteratorRowRegion it
 *     cdef int n = 0
 */

  /* 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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("pysamstats.opt.count_reads", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_it);
  __Pyx_XDECREF(__pyx_v_has_coord);
  __Pyx_XDECREF(__pyx_v_rtid);
  __Pyx_XDECREF(__pyx_v_rstart);
  __Pyx_XDECREF(__pyx_v_rend);
  __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;
  __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_ERR(1, 96, __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*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_info->itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 103, __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_ERR(1, 103, __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_ERR(1, 103, __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*> PyObject_Malloc(sizeof(Py_ssize_t) + 2)             # <<<<<<<<<<<<<<
 *             if not info.shape:
 *                 raise MemoryError()
 */
  __pyx_v_info->shape = ((Py_ssize_t *)PyObject_Malloc(((sizeof(Py_ssize_t)) + 2)));

  /* "array.pxd":106
 * 
 *             info.shape = <Py_ssize_t*> PyObject_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*> PyObject_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_ERR(1, 107, __pyx_L1_error)

    /* "array.pxd":106
 * 
 *             info.shape = <Py_ssize_t*> PyObject_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_ERR(1, 108, __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):             # <<<<<<<<<<<<<<
 *             PyObject_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):
 *             PyObject_Free(info.shape)             # <<<<<<<<<<<<<<
 * 
 *     array newarrayobject(PyTypeObject* type, Py_ssize_t size, arraydescr *descr)
 */
  PyObject_Free(__pyx_v_info->shape);

  /* "array.pxd":116
 *             info.obj = self
 * 
 *         def __releasebuffer__(self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             PyObject_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;
  __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_ERR(1, 132, __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;
  __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_ERR(1, 139, __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;
  __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_ERR(1, 149, __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;
  __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_ERR(1, 156, __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_ERR(1, 157, __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();
}
static struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat __pyx_vtable_10pysamstats_3opt_PileupStat;

static PyObject *__pyx_tp_new_10pysamstats_3opt_PileupStat(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_PileupStat *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_10pysamstats_3opt_PileupStat *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_PileupStat;
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(PyObject *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_TYPE(o)->tp_free)(o);
}

static PyTypeObject __pyx_type_10pysamstats_3opt_PileupStat = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.PileupStat", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_PileupStat), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat, /*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_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*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_10pysamstats_3opt_PileupStat, /*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_10pysamstats_3opt_CountPp __pyx_vtable_10pysamstats_3opt_CountPp;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CountPp(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CountPp *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_10pysamstats_3opt_CountPp *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_CountPp;
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_CountPp(PyObject *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_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CountPp[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_7CountPp_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_7CountPp_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CountPp = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CountPp", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CountPp), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_CountPp, /*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_BASETYPE, /*tp_flags*/
  "CountPp()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CountPp, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_7CountPp_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CountPp, /*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_10pysamstats_3opt_Coverage __pyx_vtable_10pysamstats_3opt_Coverage;

static PyObject *__pyx_tp_new_10pysamstats_3opt_Coverage(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_Coverage *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_Coverage *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_Coverage;
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_Coverage(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_Coverage *p = (struct __pyx_obj_10pysamstats_3opt_Coverage *)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->reads);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_Coverage(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_Coverage *p = (struct __pyx_obj_10pysamstats_3opt_Coverage *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_Coverage)); if (e) return e;
  if (p->reads) {
    e = (*v)(((PyObject*)p->reads), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_Coverage(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_Coverage *p = (struct __pyx_obj_10pysamstats_3opt_Coverage *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_Coverage);
  tmp = ((PyObject*)p->reads);
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_Coverage[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_8Coverage_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_8Coverage_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_Coverage = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.Coverage", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_Coverage), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_Coverage, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Coverage()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_Coverage, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_Coverage, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_Coverage, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_8Coverage_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_Coverage, /*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_10pysamstats_3opt_CountPpStrand __pyx_vtable_10pysamstats_3opt_CountPpStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CountPpStrand(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CountPpStrand *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_10pysamstats_3opt_CountPpStrand *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_CountPpStrand;
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_CountPpStrand(PyObject *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_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CountPpStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_13CountPpStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_13CountPpStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CountPpStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CountPpStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CountPpStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_CountPpStrand, /*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_BASETYPE, /*tp_flags*/
  "CountPpStrand()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CountPpStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_13CountPpStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CountPpStrand, /*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_10pysamstats_3opt_CoverageStrand __pyx_vtable_10pysamstats_3opt_CoverageStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageStrand(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CoverageStrand *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_CoverageStrand *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_CoverageStrand;
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_CoverageStrand(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_CoverageStrand *p = (struct __pyx_obj_10pysamstats_3opt_CoverageStrand *)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->reads);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_CoverageStrand(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_CoverageStrand *p = (struct __pyx_obj_10pysamstats_3opt_CoverageStrand *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_CoverageStrand)); if (e) return e;
  if (p->reads) {
    e = (*v)(((PyObject*)p->reads), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_CoverageStrand(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_CoverageStrand *p = (struct __pyx_obj_10pysamstats_3opt_CoverageStrand *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_CoverageStrand);
  tmp = ((PyObject*)p->reads);
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CoverageStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_14CoverageStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_14CoverageStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CoverageStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CoverageStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CoverageStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_CoverageStrand, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "CoverageStrand()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_CoverageStrand, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_CoverageStrand, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CoverageStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_14CoverageStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CoverageStrand, /*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_10pysamstats_3opt_CoverageExt __pyx_vtable_10pysamstats_3opt_CoverageExt;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageExt(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CoverageExt *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_CoverageExt *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_CoverageExt;
  return o;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CoverageExt[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_11CoverageExt_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_11CoverageExt_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CoverageExt = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CoverageExt", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CoverageExt), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat, /*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_BASETYPE, /*tp_flags*/
  "CoverageExt()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CoverageExt, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_11CoverageExt_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CoverageExt, /*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_10pysamstats_3opt_CountStrand __pyx_vtable_10pysamstats_3opt_CountStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CountStrand(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CountStrand *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_10pysamstats_3opt_CountStrand *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_CountStrand;
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_CountStrand(PyObject *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_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CountStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_11CountStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_11CountStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CountStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CountStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CountStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_CountStrand, /*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_BASETYPE, /*tp_flags*/
  "CountStrand()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CountStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_11CountStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CountStrand, /*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_10pysamstats_3opt_CoverageExtStrand __pyx_vtable_10pysamstats_3opt_CoverageExtStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageExtStrand(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_CoverageExtStrand;
  p->all = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  p->mate_unmapped = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  p->mate_other_chr = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  p->same_strand = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  p->faceaway = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  p->softclipped = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  p->duplicate = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_CoverageExtStrand(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *p = (struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *)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->all);
  Py_CLEAR(p->pp);
  Py_CLEAR(p->mate_unmapped);
  Py_CLEAR(p->mate_other_chr);
  Py_CLEAR(p->same_strand);
  Py_CLEAR(p->faceaway);
  Py_CLEAR(p->softclipped);
  Py_CLEAR(p->duplicate);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_CoverageExtStrand(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *p = (struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_CoverageExtStrand)); if (e) return e;
  if (p->all) {
    e = (*v)(((PyObject*)p->all), a); if (e) return e;
  }
  if (p->pp) {
    e = (*v)(((PyObject*)p->pp), a); if (e) return e;
  }
  if (p->mate_unmapped) {
    e = (*v)(((PyObject*)p->mate_unmapped), a); if (e) return e;
  }
  if (p->mate_other_chr) {
    e = (*v)(((PyObject*)p->mate_other_chr), a); if (e) return e;
  }
  if (p->same_strand) {
    e = (*v)(((PyObject*)p->same_strand), a); if (e) return e;
  }
  if (p->faceaway) {
    e = (*v)(((PyObject*)p->faceaway), a); if (e) return e;
  }
  if (p->softclipped) {
    e = (*v)(((PyObject*)p->softclipped), a); if (e) return e;
  }
  if (p->duplicate) {
    e = (*v)(((PyObject*)p->duplicate), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_CoverageExtStrand(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *p = (struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_CoverageExtStrand);
  tmp = ((PyObject*)p->all);
  p->all = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->mate_unmapped);
  p->mate_unmapped = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->mate_other_chr);
  p->mate_other_chr = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->same_strand);
  p->same_strand = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->faceaway);
  p->faceaway = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->softclipped);
  p->softclipped = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->duplicate);
  p->duplicate = ((struct __pyx_obj_10pysamstats_3opt_CountStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CoverageExtStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_17CoverageExtStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_17CoverageExtStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CoverageExtStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CoverageExtStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CoverageExtStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_CoverageExtStrand, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "CoverageExtStrand()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_CoverageExtStrand, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_CoverageExtStrand, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CoverageExtStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_17CoverageExtStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CoverageExtStrand, /*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_10pysamstats_3opt_Variation __pyx_vtable_10pysamstats_3opt_Variation;

static PyObject *__pyx_tp_new_10pysamstats_3opt_Variation(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_Variation *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_Variation *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_Variation;
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->matches = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->mismatches = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->deletions = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->insertions = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->A = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->C = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->T = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->G = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  p->N = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_Variation(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_Variation *p = (struct __pyx_obj_10pysamstats_3opt_Variation *)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->reads);
  Py_CLEAR(p->matches);
  Py_CLEAR(p->mismatches);
  Py_CLEAR(p->deletions);
  Py_CLEAR(p->insertions);
  Py_CLEAR(p->A);
  Py_CLEAR(p->C);
  Py_CLEAR(p->T);
  Py_CLEAR(p->G);
  Py_CLEAR(p->N);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_Variation(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_Variation *p = (struct __pyx_obj_10pysamstats_3opt_Variation *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_Variation)); if (e) return e;
  if (p->reads) {
    e = (*v)(((PyObject*)p->reads), a); if (e) return e;
  }
  if (p->matches) {
    e = (*v)(((PyObject*)p->matches), a); if (e) return e;
  }
  if (p->mismatches) {
    e = (*v)(((PyObject*)p->mismatches), a); if (e) return e;
  }
  if (p->deletions) {
    e = (*v)(((PyObject*)p->deletions), a); if (e) return e;
  }
  if (p->insertions) {
    e = (*v)(((PyObject*)p->insertions), a); if (e) return e;
  }
  if (p->A) {
    e = (*v)(((PyObject*)p->A), a); if (e) return e;
  }
  if (p->C) {
    e = (*v)(((PyObject*)p->C), a); if (e) return e;
  }
  if (p->T) {
    e = (*v)(((PyObject*)p->T), a); if (e) return e;
  }
  if (p->G) {
    e = (*v)(((PyObject*)p->G), a); if (e) return e;
  }
  if (p->N) {
    e = (*v)(((PyObject*)p->N), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_Variation(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_Variation *p = (struct __pyx_obj_10pysamstats_3opt_Variation *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_Variation);
  tmp = ((PyObject*)p->reads);
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->matches);
  p->matches = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->mismatches);
  p->mismatches = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->deletions);
  p->deletions = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->insertions);
  p->insertions = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->A);
  p->A = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->C);
  p->C = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->T);
  p->T = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->G);
  p->G = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->N);
  p->N = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_Variation[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_9Variation_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_9Variation_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_Variation = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.Variation", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_Variation), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_Variation, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Variation()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_Variation, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_Variation, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_Variation, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_9Variation_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_Variation, /*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_10pysamstats_3opt_VariationStrand __pyx_vtable_10pysamstats_3opt_VariationStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_VariationStrand(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_VariationStrand *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_VariationStrand *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_VariationStrand;
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->matches = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->mismatches = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->deletions = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->insertions = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->A = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->C = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->T = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->G = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  p->N = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_VariationStrand(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_VariationStrand *p = (struct __pyx_obj_10pysamstats_3opt_VariationStrand *)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->reads);
  Py_CLEAR(p->matches);
  Py_CLEAR(p->mismatches);
  Py_CLEAR(p->deletions);
  Py_CLEAR(p->insertions);
  Py_CLEAR(p->A);
  Py_CLEAR(p->C);
  Py_CLEAR(p->T);
  Py_CLEAR(p->G);
  Py_CLEAR(p->N);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_VariationStrand(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_VariationStrand *p = (struct __pyx_obj_10pysamstats_3opt_VariationStrand *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_VariationStrand)); if (e) return e;
  if (p->reads) {
    e = (*v)(((PyObject*)p->reads), a); if (e) return e;
  }
  if (p->matches) {
    e = (*v)(((PyObject*)p->matches), a); if (e) return e;
  }
  if (p->mismatches) {
    e = (*v)(((PyObject*)p->mismatches), a); if (e) return e;
  }
  if (p->deletions) {
    e = (*v)(((PyObject*)p->deletions), a); if (e) return e;
  }
  if (p->insertions) {
    e = (*v)(((PyObject*)p->insertions), a); if (e) return e;
  }
  if (p->A) {
    e = (*v)(((PyObject*)p->A), a); if (e) return e;
  }
  if (p->C) {
    e = (*v)(((PyObject*)p->C), a); if (e) return e;
  }
  if (p->T) {
    e = (*v)(((PyObject*)p->T), a); if (e) return e;
  }
  if (p->G) {
    e = (*v)(((PyObject*)p->G), a); if (e) return e;
  }
  if (p->N) {
    e = (*v)(((PyObject*)p->N), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_VariationStrand(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_VariationStrand *p = (struct __pyx_obj_10pysamstats_3opt_VariationStrand *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_VariationStrand);
  tmp = ((PyObject*)p->reads);
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->matches);
  p->matches = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->mismatches);
  p->mismatches = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->deletions);
  p->deletions = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->insertions);
  p->insertions = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->A);
  p->A = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->C);
  p->C = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->T);
  p->T = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->G);
  p->G = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->N);
  p->N = ((struct __pyx_obj_10pysamstats_3opt_CountPpStrand *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_VariationStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_15VariationStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_15VariationStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_VariationStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.VariationStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_VariationStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_VariationStrand, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "VariationStrand()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_VariationStrand, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_VariationStrand, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_VariationStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_15VariationStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_VariationStrand, /*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_10pysamstats_3opt_TlenHelper __pyx_vtable_10pysamstats_3opt_TlenHelper;

static PyObject *__pyx_tp_new_10pysamstats_3opt_TlenHelper(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_TlenHelper *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_10pysamstats_3opt_TlenHelper *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_TlenHelper;
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_TlenHelper(PyObject *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_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_TlenHelper[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_10TlenHelper_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10TlenHelper_2reset},
  {"variance", (PyCFunction)__pyx_pw_10pysamstats_3opt_10TlenHelper_5variance, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10TlenHelper_4variance},
  {"std", (PyCFunction)__pyx_pw_10pysamstats_3opt_10TlenHelper_7std, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10TlenHelper_6std},
  {"mean", (PyCFunction)__pyx_pw_10pysamstats_3opt_10TlenHelper_9mean, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10TlenHelper_8mean},
  {"rms", (PyCFunction)__pyx_pw_10pysamstats_3opt_10TlenHelper_11rms, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10TlenHelper_10rms},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_TlenHelper = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.TlenHelper", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_TlenHelper), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_TlenHelper, /*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_BASETYPE, /*tp_flags*/
  "TlenHelper()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_TlenHelper, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_10TlenHelper_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_TlenHelper, /*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_10pysamstats_3opt_Tlen __pyx_vtable_10pysamstats_3opt_Tlen;

static PyObject *__pyx_tp_new_10pysamstats_3opt_Tlen(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_Tlen *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_Tlen *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_Tlen;
  p->tlen = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  p->tlen_pp = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_Tlen(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_Tlen *p = (struct __pyx_obj_10pysamstats_3opt_Tlen *)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->tlen);
  Py_CLEAR(p->tlen_pp);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_Tlen(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_Tlen *p = (struct __pyx_obj_10pysamstats_3opt_Tlen *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_Tlen)); if (e) return e;
  if (p->tlen) {
    e = (*v)(((PyObject*)p->tlen), a); if (e) return e;
  }
  if (p->tlen_pp) {
    e = (*v)(((PyObject*)p->tlen_pp), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_Tlen(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_Tlen *p = (struct __pyx_obj_10pysamstats_3opt_Tlen *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_Tlen);
  tmp = ((PyObject*)p->tlen);
  p->tlen = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->tlen_pp);
  p->tlen_pp = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_Tlen[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_4Tlen_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_4Tlen_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_Tlen = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.Tlen", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_Tlen), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_Tlen, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Tlen()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_Tlen, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_Tlen, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_Tlen, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_4Tlen_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_Tlen, /*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_10pysamstats_3opt_TlenStrand __pyx_vtable_10pysamstats_3opt_TlenStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_TlenStrand(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_TlenStrand *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_TlenStrand *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_TlenStrand;
  p->tlen = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  p->tlen_fwd = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  p->tlen_rev = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  p->tlen_pp = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  p->tlen_pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  p->tlen_pp_rev = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_TlenStrand(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_TlenStrand *p = (struct __pyx_obj_10pysamstats_3opt_TlenStrand *)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->tlen);
  Py_CLEAR(p->tlen_fwd);
  Py_CLEAR(p->tlen_rev);
  Py_CLEAR(p->tlen_pp);
  Py_CLEAR(p->tlen_pp_fwd);
  Py_CLEAR(p->tlen_pp_rev);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_TlenStrand(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_TlenStrand *p = (struct __pyx_obj_10pysamstats_3opt_TlenStrand *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_TlenStrand)); if (e) return e;
  if (p->tlen) {
    e = (*v)(((PyObject*)p->tlen), a); if (e) return e;
  }
  if (p->tlen_fwd) {
    e = (*v)(((PyObject*)p->tlen_fwd), a); if (e) return e;
  }
  if (p->tlen_rev) {
    e = (*v)(((PyObject*)p->tlen_rev), a); if (e) return e;
  }
  if (p->tlen_pp) {
    e = (*v)(((PyObject*)p->tlen_pp), a); if (e) return e;
  }
  if (p->tlen_pp_fwd) {
    e = (*v)(((PyObject*)p->tlen_pp_fwd), a); if (e) return e;
  }
  if (p->tlen_pp_rev) {
    e = (*v)(((PyObject*)p->tlen_pp_rev), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_TlenStrand(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_TlenStrand *p = (struct __pyx_obj_10pysamstats_3opt_TlenStrand *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_TlenStrand);
  tmp = ((PyObject*)p->tlen);
  p->tlen = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->tlen_fwd);
  p->tlen_fwd = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->tlen_rev);
  p->tlen_rev = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->tlen_pp);
  p->tlen_pp = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->tlen_pp_fwd);
  p->tlen_pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->tlen_pp_rev);
  p->tlen_pp_rev = ((struct __pyx_obj_10pysamstats_3opt_TlenHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_TlenStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_10TlenStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10TlenStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_TlenStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.TlenStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_TlenStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_TlenStrand, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "TlenStrand()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_TlenStrand, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_TlenStrand, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_TlenStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_10TlenStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_TlenStrand, /*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_10pysamstats_3opt_MapqHelper __pyx_vtable_10pysamstats_3opt_MapqHelper;

static PyObject *__pyx_tp_new_10pysamstats_3opt_MapqHelper(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_MapqHelper *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_10pysamstats_3opt_MapqHelper *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_MapqHelper;
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_MapqHelper(PyObject *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_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_MapqHelper[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_10MapqHelper_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10MapqHelper_2reset},
  {"rms", (PyCFunction)__pyx_pw_10pysamstats_3opt_10MapqHelper_5rms, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10MapqHelper_4rms},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_MapqHelper = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.MapqHelper", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_MapqHelper), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_MapqHelper, /*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_BASETYPE, /*tp_flags*/
  "MapqHelper()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_MapqHelper, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_10MapqHelper_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_MapqHelper, /*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_10pysamstats_3opt_Mapq __pyx_vtable_10pysamstats_3opt_Mapq;

static PyObject *__pyx_tp_new_10pysamstats_3opt_Mapq(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_Mapq *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_Mapq *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_Mapq;
  p->all = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_Mapq(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_Mapq *p = (struct __pyx_obj_10pysamstats_3opt_Mapq *)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->all);
  Py_CLEAR(p->pp);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_Mapq(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_Mapq *p = (struct __pyx_obj_10pysamstats_3opt_Mapq *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_Mapq)); if (e) return e;
  if (p->all) {
    e = (*v)(((PyObject*)p->all), a); if (e) return e;
  }
  if (p->pp) {
    e = (*v)(((PyObject*)p->pp), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_Mapq(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_Mapq *p = (struct __pyx_obj_10pysamstats_3opt_Mapq *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_Mapq);
  tmp = ((PyObject*)p->all);
  p->all = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_Mapq[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_4Mapq_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_4Mapq_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_Mapq = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.Mapq", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_Mapq), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_Mapq, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Mapq()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_Mapq, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_Mapq, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_Mapq, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_4Mapq_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_Mapq, /*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_10pysamstats_3opt_MapqStrand __pyx_vtable_10pysamstats_3opt_MapqStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_MapqStrand(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_MapqStrand *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_MapqStrand *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_MapqStrand;
  p->all = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  p->fwd = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  p->rev = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  p->pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  p->pp_rev = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_MapqStrand(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_MapqStrand *p = (struct __pyx_obj_10pysamstats_3opt_MapqStrand *)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->all);
  Py_CLEAR(p->fwd);
  Py_CLEAR(p->rev);
  Py_CLEAR(p->pp);
  Py_CLEAR(p->pp_fwd);
  Py_CLEAR(p->pp_rev);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_MapqStrand(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_MapqStrand *p = (struct __pyx_obj_10pysamstats_3opt_MapqStrand *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_MapqStrand)); if (e) return e;
  if (p->all) {
    e = (*v)(((PyObject*)p->all), a); if (e) return e;
  }
  if (p->fwd) {
    e = (*v)(((PyObject*)p->fwd), a); if (e) return e;
  }
  if (p->rev) {
    e = (*v)(((PyObject*)p->rev), a); if (e) return e;
  }
  if (p->pp) {
    e = (*v)(((PyObject*)p->pp), a); if (e) return e;
  }
  if (p->pp_fwd) {
    e = (*v)(((PyObject*)p->pp_fwd), a); if (e) return e;
  }
  if (p->pp_rev) {
    e = (*v)(((PyObject*)p->pp_rev), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_MapqStrand(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_MapqStrand *p = (struct __pyx_obj_10pysamstats_3opt_MapqStrand *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_MapqStrand);
  tmp = ((PyObject*)p->all);
  p->all = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->fwd);
  p->fwd = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->rev);
  p->rev = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp_fwd);
  p->pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp_rev);
  p->pp_rev = ((struct __pyx_obj_10pysamstats_3opt_MapqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_MapqStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_10MapqStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10MapqStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_MapqStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.MapqStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_MapqStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_MapqStrand, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "MapqStrand()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_MapqStrand, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_MapqStrand, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_MapqStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_10MapqStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_MapqStrand, /*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_10pysamstats_3opt_BaseqHelper __pyx_vtable_10pysamstats_3opt_BaseqHelper;

static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqHelper(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_BaseqHelper *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_10pysamstats_3opt_BaseqHelper *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_BaseqHelper;
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_BaseqHelper(PyObject *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_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_BaseqHelper[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_11BaseqHelper_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_11BaseqHelper_2reset},
  {"rms", (PyCFunction)__pyx_pw_10pysamstats_3opt_11BaseqHelper_5rms, METH_NOARGS, __pyx_doc_10pysamstats_3opt_11BaseqHelper_4rms},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_BaseqHelper = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.BaseqHelper", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_BaseqHelper), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BaseqHelper, /*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_BASETYPE, /*tp_flags*/
  "BaseqHelper()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_BaseqHelper, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_11BaseqHelper_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_BaseqHelper, /*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_10pysamstats_3opt_BaseqPpHelper __pyx_vtable_10pysamstats_3opt_BaseqPpHelper;

static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqPpHelper(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *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_10pysamstats_3opt_BaseqPpHelper *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_BaseqPpHelper;
  p->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_BaseqPpHelper(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *p = (struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)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->all);
  Py_CLEAR(p->pp);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_BaseqPpHelper(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *p = (struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)o;
  if (p->all) {
    e = (*v)(((PyObject*)p->all), a); if (e) return e;
  }
  if (p->pp) {
    e = (*v)(((PyObject*)p->pp), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_BaseqPpHelper(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *p = (struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)o;
  tmp = ((PyObject*)p->all);
  p->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_BaseqPpHelper[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_13BaseqPpHelper_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_13BaseqPpHelper_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_BaseqPpHelper = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.BaseqPpHelper", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BaseqPpHelper, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "BaseqPpHelper()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_BaseqPpHelper, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_BaseqPpHelper, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_BaseqPpHelper, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_13BaseqPpHelper_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_BaseqPpHelper, /*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_10pysamstats_3opt_Baseq __pyx_vtable_10pysamstats_3opt_Baseq;

static PyObject *__pyx_tp_new_10pysamstats_3opt_Baseq(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_Baseq *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_Baseq *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_Baseq;
  p->helper = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_Baseq(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_Baseq *p = (struct __pyx_obj_10pysamstats_3opt_Baseq *)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->helper);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_Baseq(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_Baseq *p = (struct __pyx_obj_10pysamstats_3opt_Baseq *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_Baseq)); if (e) return e;
  if (p->helper) {
    e = (*v)(((PyObject*)p->helper), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_Baseq(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_Baseq *p = (struct __pyx_obj_10pysamstats_3opt_Baseq *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_Baseq);
  tmp = ((PyObject*)p->helper);
  p->helper = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_Baseq[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_5Baseq_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_5Baseq_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_Baseq = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.Baseq", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_Baseq), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_Baseq, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Baseq()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_Baseq, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_Baseq, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_Baseq, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_5Baseq_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_Baseq, /*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_10pysamstats_3opt_BaseqStrandPpHelper __pyx_vtable_10pysamstats_3opt_BaseqStrandPpHelper;

static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqStrandPpHelper(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *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_10pysamstats_3opt_BaseqStrandPpHelper *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_BaseqStrandPpHelper;
  p->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  p->fwd = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  p->rev = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  p->pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  p->pp_rev = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_BaseqStrandPpHelper(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *p = (struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)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->all);
  Py_CLEAR(p->fwd);
  Py_CLEAR(p->rev);
  Py_CLEAR(p->pp);
  Py_CLEAR(p->pp_fwd);
  Py_CLEAR(p->pp_rev);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_BaseqStrandPpHelper(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *p = (struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)o;
  if (p->all) {
    e = (*v)(((PyObject*)p->all), a); if (e) return e;
  }
  if (p->fwd) {
    e = (*v)(((PyObject*)p->fwd), a); if (e) return e;
  }
  if (p->rev) {
    e = (*v)(((PyObject*)p->rev), a); if (e) return e;
  }
  if (p->pp) {
    e = (*v)(((PyObject*)p->pp), a); if (e) return e;
  }
  if (p->pp_fwd) {
    e = (*v)(((PyObject*)p->pp_fwd), a); if (e) return e;
  }
  if (p->pp_rev) {
    e = (*v)(((PyObject*)p->pp_rev), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_BaseqStrandPpHelper(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *p = (struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)o;
  tmp = ((PyObject*)p->all);
  p->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->fwd);
  p->fwd = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->rev);
  p->rev = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp);
  p->pp = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp_fwd);
  p->pp_fwd = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pp_rev);
  p->pp_rev = ((struct __pyx_obj_10pysamstats_3opt_BaseqHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_BaseqStrandPpHelper[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_19BaseqStrandPpHelper_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_19BaseqStrandPpHelper_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_BaseqStrandPpHelper = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.BaseqStrandPpHelper", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BaseqStrandPpHelper, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "BaseqStrandPpHelper()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_BaseqStrandPpHelper, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_BaseqStrandPpHelper, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_BaseqStrandPpHelper, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_19BaseqStrandPpHelper_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_BaseqStrandPpHelper, /*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_10pysamstats_3opt_BaseqStrand __pyx_vtable_10pysamstats_3opt_BaseqStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqStrand(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_BaseqStrand *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrand *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_BaseqStrand;
  p->helper = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_BaseqStrand(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_BaseqStrand *p = (struct __pyx_obj_10pysamstats_3opt_BaseqStrand *)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->helper);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_BaseqStrand(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_BaseqStrand *p = (struct __pyx_obj_10pysamstats_3opt_BaseqStrand *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_BaseqStrand)); if (e) return e;
  if (p->helper) {
    e = (*v)(((PyObject*)p->helper), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_BaseqStrand(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_BaseqStrand *p = (struct __pyx_obj_10pysamstats_3opt_BaseqStrand *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_BaseqStrand);
  tmp = ((PyObject*)p->helper);
  p->helper = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_BaseqStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_11BaseqStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_11BaseqStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_BaseqStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.BaseqStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_BaseqStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BaseqStrand, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "BaseqStrand()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_BaseqStrand, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_BaseqStrand, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_BaseqStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_11BaseqStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_BaseqStrand, /*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_10pysamstats_3opt_BaseqExt __pyx_vtable_10pysamstats_3opt_BaseqExt;

static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqExt(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_BaseqExt *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_BaseqExt *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_BaseqExt;
  p->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)Py_None); Py_INCREF(Py_None);
  p->matches = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)Py_None); Py_INCREF(Py_None);
  p->mismatches = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_BaseqExt(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_BaseqExt *p = (struct __pyx_obj_10pysamstats_3opt_BaseqExt *)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->all);
  Py_CLEAR(p->matches);
  Py_CLEAR(p->mismatches);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_BaseqExt(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_BaseqExt *p = (struct __pyx_obj_10pysamstats_3opt_BaseqExt *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_BaseqExt)); if (e) return e;
  if (p->all) {
    e = (*v)(((PyObject*)p->all), a); if (e) return e;
  }
  if (p->matches) {
    e = (*v)(((PyObject*)p->matches), a); if (e) return e;
  }
  if (p->mismatches) {
    e = (*v)(((PyObject*)p->mismatches), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_BaseqExt(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_BaseqExt *p = (struct __pyx_obj_10pysamstats_3opt_BaseqExt *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_BaseqExt);
  tmp = ((PyObject*)p->all);
  p->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->matches);
  p->matches = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->mismatches);
  p->mismatches = ((struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_BaseqExt[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_8BaseqExt_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_8BaseqExt_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_BaseqExt = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.BaseqExt", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_BaseqExt), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BaseqExt, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "BaseqExt()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_BaseqExt, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_BaseqExt, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_BaseqExt, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_8BaseqExt_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_BaseqExt, /*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_10pysamstats_3opt_BaseqExtStrand __pyx_vtable_10pysamstats_3opt_BaseqExtStrand;

static PyObject *__pyx_tp_new_10pysamstats_3opt_BaseqExtStrand(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_BaseqExtStrand;
  p->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)Py_None); Py_INCREF(Py_None);
  p->matches = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)Py_None); Py_INCREF(Py_None);
  p->mismatches = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_BaseqExtStrand(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *p = (struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *)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->all);
  Py_CLEAR(p->matches);
  Py_CLEAR(p->mismatches);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_BaseqExtStrand(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *p = (struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_BaseqExtStrand)); if (e) return e;
  if (p->all) {
    e = (*v)(((PyObject*)p->all), a); if (e) return e;
  }
  if (p->matches) {
    e = (*v)(((PyObject*)p->matches), a); if (e) return e;
  }
  if (p->mismatches) {
    e = (*v)(((PyObject*)p->mismatches), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_BaseqExtStrand(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *p = (struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_BaseqExtStrand);
  tmp = ((PyObject*)p->all);
  p->all = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->matches);
  p->matches = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->mismatches);
  p->mismatches = ((struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_BaseqExtStrand[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_14BaseqExtStrand_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_14BaseqExtStrand_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_BaseqExtStrand = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.BaseqExtStrand", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_BaseqExtStrand), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BaseqExtStrand, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "BaseqExtStrand()", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_BaseqExtStrand, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_BaseqExtStrand, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_BaseqExtStrand, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_14BaseqExtStrand_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_BaseqExtStrand, /*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_10pysamstats_3opt_CoverageGC __pyx_vtable_10pysamstats_3opt_CoverageGC;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageGC(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CoverageGC *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_PileupStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_CoverageGC *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_PileupStat*)__pyx_vtabptr_10pysamstats_3opt_CoverageGC;
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_CoverageGC(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt_CoverageGC *p = (struct __pyx_obj_10pysamstats_3opt_CoverageGC *)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->reads);
  #if CYTHON_USE_TYPE_SLOTS
  if (PyType_IS_GC(Py_TYPE(o)->tp_base))
  #endif
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_10pysamstats_3opt_PileupStat(o);
}

static int __pyx_tp_traverse_10pysamstats_3opt_CoverageGC(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt_CoverageGC *p = (struct __pyx_obj_10pysamstats_3opt_CoverageGC *)o;
  e = ((likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) ? ((__pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse) ? __pyx_ptype_10pysamstats_3opt_PileupStat->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_10pysamstats_3opt_CoverageGC)); if (e) return e;
  if (p->reads) {
    e = (*v)(((PyObject*)p->reads), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt_CoverageGC(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt_CoverageGC *p = (struct __pyx_obj_10pysamstats_3opt_CoverageGC *)o;
  if (likely(__pyx_ptype_10pysamstats_3opt_PileupStat)) { if (__pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear) __pyx_ptype_10pysamstats_3opt_PileupStat->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_10pysamstats_3opt_CoverageGC);
  tmp = ((PyObject*)p->reads);
  p->reads = ((struct __pyx_obj_10pysamstats_3opt_CountPp *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CoverageGC[] = {
  {"reset", (PyCFunction)__pyx_pw_10pysamstats_3opt_10CoverageGC_3reset, METH_NOARGS, __pyx_doc_10pysamstats_3opt_10CoverageGC_2reset},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CoverageGC = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CoverageGC", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CoverageGC), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_CoverageGC, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "CoverageGC(window_size, window_offset)", /*tp_doc*/
  __pyx_tp_traverse_10pysamstats_3opt_CoverageGC, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt_CoverageGC, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CoverageGC, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_10CoverageGC_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CoverageGC, /*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_10pysamstats_3opt_BinnedStat __pyx_vtable_10pysamstats_3opt_BinnedStat;

static PyObject *__pyx_tp_new_10pysamstats_3opt_BinnedStat(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_BinnedStat *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_10pysamstats_3opt_BinnedStat *)o);
  p->__pyx_vtab = __pyx_vtabptr_10pysamstats_3opt_BinnedStat;
  return o;
}

static void __pyx_tp_dealloc_10pysamstats_3opt_BinnedStat(PyObject *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_TYPE(o)->tp_free)(o);
}

static PyTypeObject __pyx_type_10pysamstats_3opt_BinnedStat = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.BinnedStat", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_BinnedStat), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BinnedStat, /*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_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*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_10pysamstats_3opt_BinnedStat, /*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_10pysamstats_3opt_CoverageBinned __pyx_vtable_10pysamstats_3opt_CoverageBinned;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageBinned(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CoverageBinned *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_BinnedStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_CoverageBinned *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat*)__pyx_vtabptr_10pysamstats_3opt_CoverageBinned;
  return o;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CoverageBinned[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CoverageBinned = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CoverageBinned", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CoverageBinned), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BinnedStat, /*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_BASETYPE, /*tp_flags*/
  "CoverageBinned()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CoverageBinned, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_14CoverageBinned_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CoverageBinned, /*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_10pysamstats_3opt_CoverageExtBinned __pyx_vtable_10pysamstats_3opt_CoverageExtBinned;

static PyObject *__pyx_tp_new_10pysamstats_3opt_CoverageExtBinned(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_BinnedStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat*)__pyx_vtabptr_10pysamstats_3opt_CoverageExtBinned;
  return o;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_CoverageExtBinned[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_CoverageExtBinned = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.CoverageExtBinned", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_CoverageExtBinned), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BinnedStat, /*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_BASETYPE, /*tp_flags*/
  "CoverageExtBinned()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_CoverageExtBinned, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_17CoverageExtBinned_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_CoverageExtBinned, /*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_10pysamstats_3opt_MapqBinned __pyx_vtable_10pysamstats_3opt_MapqBinned;

static PyObject *__pyx_tp_new_10pysamstats_3opt_MapqBinned(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_MapqBinned *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_BinnedStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_MapqBinned *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat*)__pyx_vtabptr_10pysamstats_3opt_MapqBinned;
  return o;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_MapqBinned[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_MapqBinned = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.MapqBinned", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_MapqBinned), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BinnedStat, /*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_BASETYPE, /*tp_flags*/
  "MapqBinned()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_MapqBinned, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_10MapqBinned_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_MapqBinned, /*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_10pysamstats_3opt_AlignmentBinned __pyx_vtable_10pysamstats_3opt_AlignmentBinned;

static PyObject *__pyx_tp_new_10pysamstats_3opt_AlignmentBinned(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_AlignmentBinned *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_BinnedStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_AlignmentBinned *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat*)__pyx_vtabptr_10pysamstats_3opt_AlignmentBinned;
  return o;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_AlignmentBinned[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_AlignmentBinned = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.AlignmentBinned", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_AlignmentBinned), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BinnedStat, /*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_BASETYPE, /*tp_flags*/
  "AlignmentBinned()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_AlignmentBinned, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_15AlignmentBinned_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_AlignmentBinned, /*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_10pysamstats_3opt_TlenBinned __pyx_vtable_10pysamstats_3opt_TlenBinned;

static PyObject *__pyx_tp_new_10pysamstats_3opt_TlenBinned(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_10pysamstats_3opt_TlenBinned *p;
  PyObject *o = __pyx_tp_new_10pysamstats_3opt_BinnedStat(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_10pysamstats_3opt_TlenBinned *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_10pysamstats_3opt_BinnedStat*)__pyx_vtabptr_10pysamstats_3opt_TlenBinned;
  return o;
}

static PyMethodDef __pyx_methods_10pysamstats_3opt_TlenBinned[] = {
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_10pysamstats_3opt_TlenBinned = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.TlenBinned", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt_TlenBinned), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt_BinnedStat, /*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_BASETYPE, /*tp_flags*/
  "TlenBinned()", /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_10pysamstats_3opt_TlenBinned, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_10pysamstats_3opt_10TlenBinned_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10pysamstats_3opt_TlenBinned, /*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_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *__pyx_freelist_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default[8];
static int __pyx_freecount_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default = 0;

static PyObject *__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default)))) {
    o = (PyObject*)__pyx_freelist_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default[--__pyx_freecount_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default];
    memset(o, 0, sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default));
    (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_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_alignmentfile);
  Py_CLEAR(p->__pyx_v_chrom);
  Py_CLEAR(p->__pyx_v_col);
  Py_CLEAR(p->__pyx_v_end);
  Py_CLEAR(p->__pyx_v_fafile);
  Py_CLEAR(p->__pyx_v_it);
  Py_CLEAR(p->__pyx_v_max_depth);
  Py_CLEAR(p->__pyx_v_one_based);
  Py_CLEAR(p->__pyx_v_rec);
  Py_CLEAR(p->__pyx_v_start);
  Py_CLEAR(p->__pyx_v_stat);
  Py_CLEAR(p->__pyx_v_truncate);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default)))) {
    __pyx_freelist_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default[__pyx_freecount_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default++] = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *)o;
  if (p->__pyx_v_alignmentfile) {
    e = (*v)(p->__pyx_v_alignmentfile, a); if (e) return e;
  }
  if (p->__pyx_v_chrom) {
    e = (*v)(p->__pyx_v_chrom, a); if (e) return e;
  }
  if (p->__pyx_v_col) {
    e = (*v)(((PyObject*)p->__pyx_v_col), a); if (e) return e;
  }
  if (p->__pyx_v_end) {
    e = (*v)(p->__pyx_v_end, a); if (e) return e;
  }
  if (p->__pyx_v_fafile) {
    e = (*v)(p->__pyx_v_fafile, a); if (e) return e;
  }
  if (p->__pyx_v_it) {
    e = (*v)(p->__pyx_v_it, a); if (e) return e;
  }
  if (p->__pyx_v_max_depth) {
    e = (*v)(p->__pyx_v_max_depth, a); if (e) return e;
  }
  if (p->__pyx_v_one_based) {
    e = (*v)(p->__pyx_v_one_based, a); if (e) return e;
  }
  if (p->__pyx_v_rec) {
    e = (*v)(p->__pyx_v_rec, a); if (e) return e;
  }
  if (p->__pyx_v_start) {
    e = (*v)(p->__pyx_v_start, a); if (e) return e;
  }
  if (p->__pyx_v_stat) {
    e = (*v)(p->__pyx_v_stat, a); if (e) return e;
  }
  if (p->__pyx_v_truncate) {
    e = (*v)(p->__pyx_v_truncate, 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_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default *)o;
  tmp = ((PyObject*)p->__pyx_v_alignmentfile);
  p->__pyx_v_alignmentfile = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_chrom);
  p->__pyx_v_chrom = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_col);
  p->__pyx_v_col = ((struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_end);
  p->__pyx_v_end = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_fafile);
  p->__pyx_v_fafile = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_it);
  p->__pyx_v_it = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_max_depth);
  p->__pyx_v_max_depth = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_one_based);
  p->__pyx_v_one_based = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_rec);
  p->__pyx_v_rec = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_start);
  p->__pyx_v_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_stat);
  p->__pyx_v_stat = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_truncate);
  p->__pyx_v_truncate = 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_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.__pyx_scope_struct__iter_pileup_default", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default, /*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_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default, /*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_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default, /*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_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *__pyx_freelist_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom[8];
static int __pyx_freecount_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom = 0;

static PyObject *__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom)))) {
    o = (PyObject*)__pyx_freelist_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom[--__pyx_freecount_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom];
    memset(o, 0, sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom));
    (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_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_alignmentfile);
  Py_CLEAR(p->__pyx_v_chrom);
  Py_CLEAR(p->__pyx_v_col);
  Py_CLEAR(p->__pyx_v_end);
  Py_CLEAR(p->__pyx_v_fafile);
  Py_CLEAR(p->__pyx_v_it);
  Py_CLEAR(p->__pyx_v_max_depth);
  Py_CLEAR(p->__pyx_v_min_baseq);
  Py_CLEAR(p->__pyx_v_min_mapq);
  Py_CLEAR(p->__pyx_v_no_del);
  Py_CLEAR(p->__pyx_v_no_dup);
  Py_CLEAR(p->__pyx_v_one_based);
  Py_CLEAR(p->__pyx_v_rec);
  Py_CLEAR(p->__pyx_v_refbase);
  Py_CLEAR(p->__pyx_v_start);
  Py_CLEAR(p->__pyx_v_stat);
  Py_CLEAR(p->__pyx_v_truncate);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom)))) {
    __pyx_freelist_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom[__pyx_freecount_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom++] = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *)o;
  if (p->__pyx_v_alignmentfile) {
    e = (*v)(p->__pyx_v_alignmentfile, a); if (e) return e;
  }
  if (p->__pyx_v_chrom) {
    e = (*v)(p->__pyx_v_chrom, a); if (e) return e;
  }
  if (p->__pyx_v_col) {
    e = (*v)(((PyObject*)p->__pyx_v_col), a); if (e) return e;
  }
  if (p->__pyx_v_end) {
    e = (*v)(p->__pyx_v_end, a); if (e) return e;
  }
  if (p->__pyx_v_fafile) {
    e = (*v)(p->__pyx_v_fafile, a); if (e) return e;
  }
  if (p->__pyx_v_it) {
    e = (*v)(p->__pyx_v_it, a); if (e) return e;
  }
  if (p->__pyx_v_max_depth) {
    e = (*v)(p->__pyx_v_max_depth, a); if (e) return e;
  }
  if (p->__pyx_v_min_baseq) {
    e = (*v)(p->__pyx_v_min_baseq, a); if (e) return e;
  }
  if (p->__pyx_v_min_mapq) {
    e = (*v)(p->__pyx_v_min_mapq, a); if (e) return e;
  }
  if (p->__pyx_v_no_del) {
    e = (*v)(p->__pyx_v_no_del, a); if (e) return e;
  }
  if (p->__pyx_v_no_dup) {
    e = (*v)(p->__pyx_v_no_dup, a); if (e) return e;
  }
  if (p->__pyx_v_one_based) {
    e = (*v)(p->__pyx_v_one_based, a); if (e) return e;
  }
  if (p->__pyx_v_rec) {
    e = (*v)(p->__pyx_v_rec, a); if (e) return e;
  }
  if (p->__pyx_v_refbase) {
    e = (*v)(p->__pyx_v_refbase, a); if (e) return e;
  }
  if (p->__pyx_v_start) {
    e = (*v)(p->__pyx_v_start, a); if (e) return e;
  }
  if (p->__pyx_v_stat) {
    e = (*v)(((PyObject*)p->__pyx_v_stat), a); if (e) return e;
  }
  if (p->__pyx_v_truncate) {
    e = (*v)(p->__pyx_v_truncate, 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_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom *)o;
  tmp = ((PyObject*)p->__pyx_v_alignmentfile);
  p->__pyx_v_alignmentfile = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_chrom);
  p->__pyx_v_chrom = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_col);
  p->__pyx_v_col = ((struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_end);
  p->__pyx_v_end = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_fafile);
  p->__pyx_v_fafile = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_it);
  p->__pyx_v_it = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_max_depth);
  p->__pyx_v_max_depth = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_min_baseq);
  p->__pyx_v_min_baseq = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_min_mapq);
  p->__pyx_v_min_mapq = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_no_del);
  p->__pyx_v_no_del = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_no_dup);
  p->__pyx_v_no_dup = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_one_based);
  p->__pyx_v_one_based = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_rec);
  p->__pyx_v_rec = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_refbase);
  p->__pyx_v_refbase = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_start);
  p->__pyx_v_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_stat);
  p->__pyx_v_stat = ((struct __pyx_obj_10pysamstats_3opt_PileupStat *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_truncate);
  p->__pyx_v_truncate = 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_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.__pyx_scope_struct_1_iter_pileup_padded_chrom", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom, /*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_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom, /*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_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom, /*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_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *__pyx_freelist_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom[8];
static int __pyx_freecount_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom = 0;

static PyObject *__pyx_tp_new_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom)))) {
    o = (PyObject*)__pyx_freelist_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom[--__pyx_freecount_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom];
    memset(o, 0, sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom));
    (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_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom(PyObject *o) {
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_alignmentfile);
  Py_CLEAR(p->__pyx_v_chrom);
  Py_CLEAR(p->__pyx_v_end);
  Py_CLEAR(p->__pyx_v_fafile);
  Py_CLEAR(p->__pyx_v_it);
  Py_CLEAR(p->__pyx_v_one_based);
  Py_CLEAR(p->__pyx_v_pos);
  Py_CLEAR(p->__pyx_v_rec);
  Py_CLEAR(p->__pyx_v_start);
  Py_CLEAR(p->__pyx_v_stat);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom)))) {
    __pyx_freelist_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom[__pyx_freecount_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom++] = ((struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *)o;
  if (p->__pyx_v_alignmentfile) {
    e = (*v)(((PyObject*)p->__pyx_v_alignmentfile), a); if (e) return e;
  }
  if (p->__pyx_v_chrom) {
    e = (*v)(p->__pyx_v_chrom, a); if (e) return e;
  }
  if (p->__pyx_v_end) {
    e = (*v)(p->__pyx_v_end, a); if (e) return e;
  }
  if (p->__pyx_v_fafile) {
    e = (*v)(((PyObject*)p->__pyx_v_fafile), a); if (e) return e;
  }
  if (p->__pyx_v_it) {
    e = (*v)(((PyObject*)p->__pyx_v_it), a); if (e) return e;
  }
  if (p->__pyx_v_one_based) {
    e = (*v)(p->__pyx_v_one_based, a); if (e) return e;
  }
  if (p->__pyx_v_pos) {
    e = (*v)(p->__pyx_v_pos, a); if (e) return e;
  }
  if (p->__pyx_v_rec) {
    e = (*v)(p->__pyx_v_rec, a); if (e) return e;
  }
  if (p->__pyx_v_start) {
    e = (*v)(p->__pyx_v_start, a); if (e) return e;
  }
  if (p->__pyx_v_stat) {
    e = (*v)(((PyObject*)p->__pyx_v_stat), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *p = (struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom *)o;
  tmp = ((PyObject*)p->__pyx_v_alignmentfile);
  p->__pyx_v_alignmentfile = ((struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_chrom);
  p->__pyx_v_chrom = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_end);
  p->__pyx_v_end = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_fafile);
  p->__pyx_v_fafile = ((struct __pyx_obj_5pysam_9libcfaidx_FastaFile *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_it);
  p->__pyx_v_it = ((struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_one_based);
  p->__pyx_v_one_based = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_pos);
  p->__pyx_v_pos = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_rec);
  p->__pyx_v_rec = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_start);
  p->__pyx_v_start = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_stat);
  p->__pyx_v_stat = ((struct __pyx_obj_10pysamstats_3opt_BinnedStat *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom = {
  PyVarObject_HEAD_INIT(0, 0)
  "pysamstats.opt.__pyx_scope_struct_2_iter_binned_chrom", /*tp_name*/
  sizeof(struct __pyx_obj_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom, /*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_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom, /*tp_traverse*/
  __pyx_tp_clear_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom, /*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_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom, /*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[] = {
  {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
    "opt",
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_b_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 0, 1},
  {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
  {&__pyx_n_s_A_fwd, __pyx_k_A_fwd, sizeof(__pyx_k_A_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_A_pp, __pyx_k_A_pp, sizeof(__pyx_k_A_pp), 0, 0, 1, 1},
  {&__pyx_n_s_A_pp_fwd, __pyx_k_A_pp_fwd, sizeof(__pyx_k_A_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_A_pp_rev, __pyx_k_A_pp_rev, sizeof(__pyx_k_A_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_A_rev, __pyx_k_A_rev, sizeof(__pyx_k_A_rev), 0, 0, 1, 1},
  {&__pyx_n_b_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 0, 0, 1},
  {&__pyx_n_s_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 0, 1, 1},
  {&__pyx_n_s_C_fwd, __pyx_k_C_fwd, sizeof(__pyx_k_C_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_C_pp, __pyx_k_C_pp, sizeof(__pyx_k_C_pp), 0, 0, 1, 1},
  {&__pyx_n_s_C_pp_fwd, __pyx_k_C_pp_fwd, sizeof(__pyx_k_C_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_C_pp_rev, __pyx_k_C_pp_rev, sizeof(__pyx_k_C_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_C_rev, __pyx_k_C_rev, sizeof(__pyx_k_C_rev), 0, 0, 1, 1},
  {&__pyx_n_s_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 0, 1, 1},
  {&__pyx_n_b_G, __pyx_k_G, sizeof(__pyx_k_G), 0, 0, 0, 1},
  {&__pyx_n_s_G, __pyx_k_G, sizeof(__pyx_k_G), 0, 0, 1, 1},
  {&__pyx_n_s_G_fwd, __pyx_k_G_fwd, sizeof(__pyx_k_G_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_G_pp, __pyx_k_G_pp, sizeof(__pyx_k_G_pp), 0, 0, 1, 1},
  {&__pyx_n_s_G_pp_fwd, __pyx_k_G_pp_fwd, sizeof(__pyx_k_G_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_G_pp_rev, __pyx_k_G_pp_rev, sizeof(__pyx_k_G_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_G_rev, __pyx_k_G_rev, sizeof(__pyx_k_G_rev), 0, 0, 1, 1},
  {&__pyx_n_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 1},
  {&__pyx_n_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 1},
  {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1},
  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  {&__pyx_n_b_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 0, 1},
  {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1},
  {&__pyx_n_s_N_fwd, __pyx_k_N_fwd, sizeof(__pyx_k_N_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_N_pp, __pyx_k_N_pp, sizeof(__pyx_k_N_pp), 0, 0, 1, 1},
  {&__pyx_n_s_N_pp_fwd, __pyx_k_N_pp_fwd, sizeof(__pyx_k_N_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_N_pp_rev, __pyx_k_N_pp_rev, sizeof(__pyx_k_N_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_N_rev, __pyx_k_N_rev, sizeof(__pyx_k_N_rev), 0, 0, 1, 1},
  {&__pyx_n_s_P, __pyx_k_P, sizeof(__pyx_k_P), 0, 0, 1, 1},
  {&__pyx_n_s_PY2, __pyx_k_PY2, sizeof(__pyx_k_PY2), 0, 0, 1, 1},
  {&__pyx_n_s_S, __pyx_k_S, sizeof(__pyx_k_S), 0, 0, 1, 1},
  {&__pyx_n_b_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 0, 1},
  {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1},
  {&__pyx_n_s_T_fwd, __pyx_k_T_fwd, sizeof(__pyx_k_T_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_T_pp, __pyx_k_T_pp, sizeof(__pyx_k_T_pp), 0, 0, 1, 1},
  {&__pyx_n_s_T_pp_fwd, __pyx_k_T_pp_fwd, sizeof(__pyx_k_T_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_T_pp_rev, __pyx_k_T_pp_rev, sizeof(__pyx_k_T_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_T_rev, __pyx_k_T_rev, sizeof(__pyx_k_T_rev), 0, 0, 1, 1},
  {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1},
  {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
  {&__pyx_n_s_alignmentfile, __pyx_k_alignmentfile, sizeof(__pyx_k_alignmentfile), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 0, 1, 1},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_n_s_bases_all, __pyx_k_bases_all, sizeof(__pyx_k_bases_all), 0, 0, 1, 1},
  {&__pyx_n_s_bin_end, __pyx_k_bin_end, sizeof(__pyx_k_bin_end), 0, 0, 1, 1},
  {&__pyx_n_s_bin_start, __pyx_k_bin_start, sizeof(__pyx_k_bin_start), 0, 0, 1, 1},
  {&__pyx_n_s_chain, __pyx_k_chain, sizeof(__pyx_k_chain), 0, 0, 1, 1},
  {&__pyx_n_s_chrlen, __pyx_k_chrlen, sizeof(__pyx_k_chrlen), 0, 0, 1, 1},
  {&__pyx_n_s_chrom, __pyx_k_chrom, sizeof(__pyx_k_chrom), 0, 0, 1, 1},
  {&__pyx_kp_s_chromosome_is_None, __pyx_k_chromosome_is_None, sizeof(__pyx_k_chromosome_is_None), 0, 0, 1, 0},
  {&__pyx_kp_s_chromosome_not_in_SAM_references, __pyx_k_chromosome_not_in_SAM_references, sizeof(__pyx_k_chromosome_not_in_SAM_references), 0, 0, 1, 0},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1},
  {&__pyx_n_s_count, __pyx_k_count, sizeof(__pyx_k_count), 0, 0, 1, 1},
  {&__pyx_n_s_count_reads, __pyx_k_count_reads, sizeof(__pyx_k_count_reads), 0, 0, 1, 1},
  {&__pyx_n_s_curpos, __pyx_k_curpos, sizeof(__pyx_k_curpos), 0, 0, 1, 1},
  {&__pyx_n_s_deletions, __pyx_k_deletions, sizeof(__pyx_k_deletions), 0, 0, 1, 1},
  {&__pyx_n_s_deletions_fwd, __pyx_k_deletions_fwd, sizeof(__pyx_k_deletions_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_deletions_pp, __pyx_k_deletions_pp, sizeof(__pyx_k_deletions_pp), 0, 0, 1, 1},
  {&__pyx_n_s_deletions_pp_fwd, __pyx_k_deletions_pp_fwd, sizeof(__pyx_k_deletions_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_deletions_pp_rev, __pyx_k_deletions_pp_rev, sizeof(__pyx_k_deletions_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_deletions_rev, __pyx_k_deletions_rev, sizeof(__pyx_k_deletions_rev), 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_n_s_fafile, __pyx_k_fafile, sizeof(__pyx_k_fafile), 0, 0, 1, 1},
  {&__pyx_n_s_fetch, __pyx_k_fetch, sizeof(__pyx_k_fetch), 0, 0, 1, 1},
  {&__pyx_n_s_gc, __pyx_k_gc, sizeof(__pyx_k_gc), 0, 0, 1, 1},
  {&__pyx_n_s_get_refbase, __pyx_k_get_refbase, sizeof(__pyx_k_get_refbase), 0, 0, 1, 1},
  {&__pyx_n_s_getrname, __pyx_k_getrname, sizeof(__pyx_k_getrname), 0, 0, 1, 1},
  {&__pyx_n_s_has_coord, __pyx_k_has_coord, sizeof(__pyx_k_has_coord), 0, 0, 1, 1},
  {&__pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_k_home_aliman_src_github_alimanfo, sizeof(__pyx_k_home_aliman_src_github_alimanfo), 0, 0, 1, 0},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_insertions, __pyx_k_insertions, sizeof(__pyx_k_insertions), 0, 0, 1, 1},
  {&__pyx_n_s_insertions_fwd, __pyx_k_insertions_fwd, sizeof(__pyx_k_insertions_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_insertions_pp, __pyx_k_insertions_pp, sizeof(__pyx_k_insertions_pp), 0, 0, 1, 1},
  {&__pyx_n_s_insertions_pp_fwd, __pyx_k_insertions_pp_fwd, sizeof(__pyx_k_insertions_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_insertions_pp_rev, __pyx_k_insertions_pp_rev, sizeof(__pyx_k_insertions_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_insertions_rev, __pyx_k_insertions_rev, sizeof(__pyx_k_insertions_rev), 0, 0, 1, 1},
  {&__pyx_n_s_it, __pyx_k_it, sizeof(__pyx_k_it), 0, 0, 1, 1},
  {&__pyx_n_s_itc, __pyx_k_itc, sizeof(__pyx_k_itc), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_iter_binned, __pyx_k_iter_binned, sizeof(__pyx_k_iter_binned), 0, 0, 1, 1},
  {&__pyx_n_s_iter_binned_chrom, __pyx_k_iter_binned_chrom, sizeof(__pyx_k_iter_binned_chrom), 0, 0, 1, 1},
  {&__pyx_n_s_iter_pileup, __pyx_k_iter_pileup, sizeof(__pyx_k_iter_pileup), 0, 0, 1, 1},
  {&__pyx_n_s_iter_pileup_default, __pyx_k_iter_pileup_default, sizeof(__pyx_k_iter_pileup_default), 0, 0, 1, 1},
  {&__pyx_n_s_iter_pileup_padded, __pyx_k_iter_pileup_padded, sizeof(__pyx_k_iter_pileup_padded), 0, 0, 1, 1},
  {&__pyx_n_s_iter_pileup_padded_chrom, __pyx_k_iter_pileup_padded_chrom, sizeof(__pyx_k_iter_pileup_padded_chrom), 0, 0, 1, 1},
  {&__pyx_n_s_itertools, __pyx_k_itertools, sizeof(__pyx_k_itertools), 0, 0, 1, 1},
  {&__pyx_n_s_its, __pyx_k_its, sizeof(__pyx_k_its), 0, 0, 1, 1},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_n_s_lengths, __pyx_k_lengths, sizeof(__pyx_k_lengths), 0, 0, 1, 1},
  {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_matches, __pyx_k_matches, sizeof(__pyx_k_matches), 0, 0, 1, 1},
  {&__pyx_n_s_matches_fwd, __pyx_k_matches_fwd, sizeof(__pyx_k_matches_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_matches_pp, __pyx_k_matches_pp, sizeof(__pyx_k_matches_pp), 0, 0, 1, 1},
  {&__pyx_n_s_matches_pp_fwd, __pyx_k_matches_pp_fwd, sizeof(__pyx_k_matches_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_matches_pp_rev, __pyx_k_matches_pp_rev, sizeof(__pyx_k_matches_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_matches_rev, __pyx_k_matches_rev, sizeof(__pyx_k_matches_rev), 0, 0, 1, 1},
  {&__pyx_n_s_max_depth, __pyx_k_max_depth, sizeof(__pyx_k_max_depth), 0, 0, 1, 1},
  {&__pyx_n_s_max_mapq, __pyx_k_max_mapq, sizeof(__pyx_k_max_mapq), 0, 0, 1, 1},
  {&__pyx_n_s_max_mapq_fwd, __pyx_k_max_mapq_fwd, sizeof(__pyx_k_max_mapq_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_max_mapq_pp, __pyx_k_max_mapq_pp, sizeof(__pyx_k_max_mapq_pp), 0, 0, 1, 1},
  {&__pyx_n_s_max_mapq_pp_fwd, __pyx_k_max_mapq_pp_fwd, sizeof(__pyx_k_max_mapq_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_max_mapq_pp_rev, __pyx_k_max_mapq_pp_rev, sizeof(__pyx_k_max_mapq_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_max_mapq_rev, __pyx_k_max_mapq_rev, sizeof(__pyx_k_max_mapq_rev), 0, 0, 1, 1},
  {&__pyx_n_s_mean, __pyx_k_mean, sizeof(__pyx_k_mean), 0, 0, 1, 1},
  {&__pyx_n_s_mean_tlen, __pyx_k_mean_tlen, sizeof(__pyx_k_mean_tlen), 0, 0, 1, 1},
  {&__pyx_n_s_mean_tlen_fwd, __pyx_k_mean_tlen_fwd, sizeof(__pyx_k_mean_tlen_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_mean_tlen_pp, __pyx_k_mean_tlen_pp, sizeof(__pyx_k_mean_tlen_pp), 0, 0, 1, 1},
  {&__pyx_n_s_mean_tlen_pp_fwd, __pyx_k_mean_tlen_pp_fwd, sizeof(__pyx_k_mean_tlen_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_mean_tlen_pp_rev, __pyx_k_mean_tlen_pp_rev, sizeof(__pyx_k_mean_tlen_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_mean_tlen_rev, __pyx_k_mean_tlen_rev, sizeof(__pyx_k_mean_tlen_rev), 0, 0, 1, 1},
  {&__pyx_n_s_min_baseq, __pyx_k_min_baseq, sizeof(__pyx_k_min_baseq), 0, 0, 1, 1},
  {&__pyx_n_s_min_mapq, __pyx_k_min_mapq, sizeof(__pyx_k_min_mapq), 0, 0, 1, 1},
  {&__pyx_n_s_mismatches, __pyx_k_mismatches, sizeof(__pyx_k_mismatches), 0, 0, 1, 1},
  {&__pyx_n_s_mismatches_fwd, __pyx_k_mismatches_fwd, sizeof(__pyx_k_mismatches_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_mismatches_pp, __pyx_k_mismatches_pp, sizeof(__pyx_k_mismatches_pp), 0, 0, 1, 1},
  {&__pyx_n_s_mismatches_pp_fwd, __pyx_k_mismatches_pp_fwd, sizeof(__pyx_k_mismatches_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_mismatches_pp_rev, __pyx_k_mismatches_pp_rev, sizeof(__pyx_k_mismatches_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_mismatches_rev, __pyx_k_mismatches_rev, sizeof(__pyx_k_mismatches_rev), 0, 0, 1, 1},
  {&__pyx_n_s_multiple_iterators, __pyx_k_multiple_iterators, sizeof(__pyx_k_multiple_iterators), 0, 0, 1, 1},
  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
  {&__pyx_n_s_no_del, __pyx_k_no_del, sizeof(__pyx_k_no_del), 0, 0, 1, 1},
  {&__pyx_n_s_no_dup, __pyx_k_no_dup, sizeof(__pyx_k_no_dup), 0, 0, 1, 1},
  {&__pyx_n_s_normalise_coords, __pyx_k_normalise_coords, sizeof(__pyx_k_normalise_coords), 0, 0, 1, 1},
  {&__pyx_n_s_one_based, __pyx_k_one_based, sizeof(__pyx_k_one_based), 0, 0, 1, 1},
  {&__pyx_n_s_pad, __pyx_k_pad, sizeof(__pyx_k_pad), 0, 0, 1, 1},
  {&__pyx_n_s_parse_region, __pyx_k_parse_region, sizeof(__pyx_k_parse_region), 0, 0, 1, 1},
  {&__pyx_n_s_pileup, __pyx_k_pileup, sizeof(__pyx_k_pileup), 0, 0, 1, 1},
  {&__pyx_n_s_plp, __pyx_k_plp, sizeof(__pyx_k_plp), 0, 0, 1, 1},
  {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1},
  {&__pyx_n_s_pysamstats_opt, __pyx_k_pysamstats_opt, sizeof(__pyx_k_pysamstats_opt), 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_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
  {&__pyx_n_s_reads_all, __pyx_k_reads_all, sizeof(__pyx_k_reads_all), 0, 0, 1, 1},
  {&__pyx_n_s_reads_duplicate, __pyx_k_reads_duplicate, sizeof(__pyx_k_reads_duplicate), 0, 0, 1, 1},
  {&__pyx_n_s_reads_duplicate_fwd, __pyx_k_reads_duplicate_fwd, sizeof(__pyx_k_reads_duplicate_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_duplicate_rev, __pyx_k_reads_duplicate_rev, sizeof(__pyx_k_reads_duplicate_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_faceaway, __pyx_k_reads_faceaway, sizeof(__pyx_k_reads_faceaway), 0, 0, 1, 1},
  {&__pyx_n_s_reads_faceaway_fwd, __pyx_k_reads_faceaway_fwd, sizeof(__pyx_k_reads_faceaway_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_faceaway_rev, __pyx_k_reads_faceaway_rev, sizeof(__pyx_k_reads_faceaway_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_fwd, __pyx_k_reads_fwd, sizeof(__pyx_k_reads_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mapq0, __pyx_k_reads_mapq0, sizeof(__pyx_k_reads_mapq0), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mapq0_fwd, __pyx_k_reads_mapq0_fwd, sizeof(__pyx_k_reads_mapq0_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mapq0_pp, __pyx_k_reads_mapq0_pp, sizeof(__pyx_k_reads_mapq0_pp), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mapq0_pp_fwd, __pyx_k_reads_mapq0_pp_fwd, sizeof(__pyx_k_reads_mapq0_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mapq0_pp_rev, __pyx_k_reads_mapq0_pp_rev, sizeof(__pyx_k_reads_mapq0_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mapq0_rev, __pyx_k_reads_mapq0_rev, sizeof(__pyx_k_reads_mapq0_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_other_chr, __pyx_k_reads_mate_other_chr, sizeof(__pyx_k_reads_mate_other_chr), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_other_chr_fwd, __pyx_k_reads_mate_other_chr_fwd, sizeof(__pyx_k_reads_mate_other_chr_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_other_chr_rev, __pyx_k_reads_mate_other_chr_rev, sizeof(__pyx_k_reads_mate_other_chr_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_same_strand, __pyx_k_reads_mate_same_strand, sizeof(__pyx_k_reads_mate_same_strand), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_same_strand_fwd, __pyx_k_reads_mate_same_strand_fwd, sizeof(__pyx_k_reads_mate_same_strand_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_same_strand_rev, __pyx_k_reads_mate_same_strand_rev, sizeof(__pyx_k_reads_mate_same_strand_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_unmapped, __pyx_k_reads_mate_unmapped, sizeof(__pyx_k_reads_mate_unmapped), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_unmapped_fwd, __pyx_k_reads_mate_unmapped_fwd, sizeof(__pyx_k_reads_mate_unmapped_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_mate_unmapped_rev, __pyx_k_reads_mate_unmapped_rev, sizeof(__pyx_k_reads_mate_unmapped_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_paired, __pyx_k_reads_paired, sizeof(__pyx_k_reads_paired), 0, 0, 1, 1},
  {&__pyx_n_s_reads_paired_fwd, __pyx_k_reads_paired_fwd, sizeof(__pyx_k_reads_paired_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_paired_rev, __pyx_k_reads_paired_rev, sizeof(__pyx_k_reads_paired_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_pp, __pyx_k_reads_pp, sizeof(__pyx_k_reads_pp), 0, 0, 1, 1},
  {&__pyx_n_s_reads_pp_fwd, __pyx_k_reads_pp_fwd, sizeof(__pyx_k_reads_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_pp_rev, __pyx_k_reads_pp_rev, sizeof(__pyx_k_reads_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_rev, __pyx_k_reads_rev, sizeof(__pyx_k_reads_rev), 0, 0, 1, 1},
  {&__pyx_n_s_reads_softclipped, __pyx_k_reads_softclipped, sizeof(__pyx_k_reads_softclipped), 0, 0, 1, 1},
  {&__pyx_n_s_reads_softclipped_fwd, __pyx_k_reads_softclipped_fwd, sizeof(__pyx_k_reads_softclipped_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_reads_softclipped_rev, __pyx_k_reads_softclipped_rev, sizeof(__pyx_k_reads_softclipped_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rec, __pyx_k_rec, sizeof(__pyx_k_rec), 0, 0, 1, 1},
  {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
  {&__pyx_n_s_refbase, __pyx_k_refbase, sizeof(__pyx_k_refbase), 0, 0, 1, 1},
  {&__pyx_n_s_reference, __pyx_k_reference, sizeof(__pyx_k_reference), 0, 0, 1, 1},
  {&__pyx_n_s_references, __pyx_k_references, sizeof(__pyx_k_references), 0, 0, 1, 1},
  {&__pyx_n_s_rend, __pyx_k_rend, sizeof(__pyx_k_rend), 0, 0, 1, 1},
  {&__pyx_n_s_reset, __pyx_k_reset, sizeof(__pyx_k_reset), 0, 0, 1, 1},
  {&__pyx_n_s_rms, __pyx_k_rms, sizeof(__pyx_k_rms), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq, __pyx_k_rms_baseq, sizeof(__pyx_k_rms_baseq), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_fwd, __pyx_k_rms_baseq_fwd, sizeof(__pyx_k_rms_baseq_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_matches, __pyx_k_rms_baseq_matches, sizeof(__pyx_k_rms_baseq_matches), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_matches_fwd, __pyx_k_rms_baseq_matches_fwd, sizeof(__pyx_k_rms_baseq_matches_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_matches_pp, __pyx_k_rms_baseq_matches_pp, sizeof(__pyx_k_rms_baseq_matches_pp), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_matches_pp_fwd, __pyx_k_rms_baseq_matches_pp_fwd, sizeof(__pyx_k_rms_baseq_matches_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_matches_pp_rev, __pyx_k_rms_baseq_matches_pp_rev, sizeof(__pyx_k_rms_baseq_matches_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_matches_rev, __pyx_k_rms_baseq_matches_rev, sizeof(__pyx_k_rms_baseq_matches_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_mismatches, __pyx_k_rms_baseq_mismatches, sizeof(__pyx_k_rms_baseq_mismatches), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_mismatches_fwd, __pyx_k_rms_baseq_mismatches_fwd, sizeof(__pyx_k_rms_baseq_mismatches_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_mismatches_pp, __pyx_k_rms_baseq_mismatches_pp, sizeof(__pyx_k_rms_baseq_mismatches_pp), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_mismatches_pp_fwd, __pyx_k_rms_baseq_mismatches_pp_fwd, sizeof(__pyx_k_rms_baseq_mismatches_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_mismatches_pp_rev, __pyx_k_rms_baseq_mismatches_pp_rev, sizeof(__pyx_k_rms_baseq_mismatches_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_mismatches_rev, __pyx_k_rms_baseq_mismatches_rev, sizeof(__pyx_k_rms_baseq_mismatches_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_pp, __pyx_k_rms_baseq_pp, sizeof(__pyx_k_rms_baseq_pp), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_pp_fwd, __pyx_k_rms_baseq_pp_fwd, sizeof(__pyx_k_rms_baseq_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_pp_rev, __pyx_k_rms_baseq_pp_rev, sizeof(__pyx_k_rms_baseq_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_baseq_rev, __pyx_k_rms_baseq_rev, sizeof(__pyx_k_rms_baseq_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_mapq, __pyx_k_rms_mapq, sizeof(__pyx_k_rms_mapq), 0, 0, 1, 1},
  {&__pyx_n_s_rms_mapq_fwd, __pyx_k_rms_mapq_fwd, sizeof(__pyx_k_rms_mapq_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_mapq_pp, __pyx_k_rms_mapq_pp, sizeof(__pyx_k_rms_mapq_pp), 0, 0, 1, 1},
  {&__pyx_n_s_rms_mapq_pp_fwd, __pyx_k_rms_mapq_pp_fwd, sizeof(__pyx_k_rms_mapq_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_mapq_pp_rev, __pyx_k_rms_mapq_pp_rev, sizeof(__pyx_k_rms_mapq_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_mapq_rev, __pyx_k_rms_mapq_rev, sizeof(__pyx_k_rms_mapq_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_tlen, __pyx_k_rms_tlen, sizeof(__pyx_k_rms_tlen), 0, 0, 1, 1},
  {&__pyx_n_s_rms_tlen_fwd, __pyx_k_rms_tlen_fwd, sizeof(__pyx_k_rms_tlen_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_tlen_pp, __pyx_k_rms_tlen_pp, sizeof(__pyx_k_rms_tlen_pp), 0, 0, 1, 1},
  {&__pyx_n_s_rms_tlen_pp_fwd, __pyx_k_rms_tlen_pp_fwd, sizeof(__pyx_k_rms_tlen_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_rms_tlen_pp_rev, __pyx_k_rms_tlen_pp_rev, sizeof(__pyx_k_rms_tlen_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rms_tlen_rev, __pyx_k_rms_tlen_rev, sizeof(__pyx_k_rms_tlen_rev), 0, 0, 1, 1},
  {&__pyx_n_s_rootmean, __pyx_k_rootmean, sizeof(__pyx_k_rootmean), 0, 0, 1, 1},
  {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1},
  {&__pyx_n_s_rstart, __pyx_k_rstart, sizeof(__pyx_k_rstart), 0, 0, 1, 1},
  {&__pyx_n_s_rtid, __pyx_k_rtid, sizeof(__pyx_k_rtid), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_sqsum, __pyx_k_sqsum, sizeof(__pyx_k_sqsum), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_stat, __pyx_k_stat, sizeof(__pyx_k_stat), 0, 0, 1, 1},
  {&__pyx_n_s_stat_pileup, __pyx_k_stat_pileup, sizeof(__pyx_k_stat_pileup), 0, 0, 1, 1},
  {&__pyx_n_s_std, __pyx_k_std, sizeof(__pyx_k_std), 0, 0, 1, 1},
  {&__pyx_n_s_std_tlen, __pyx_k_std_tlen, sizeof(__pyx_k_std_tlen), 0, 0, 1, 1},
  {&__pyx_n_s_std_tlen_fwd, __pyx_k_std_tlen_fwd, sizeof(__pyx_k_std_tlen_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_std_tlen_pp, __pyx_k_std_tlen_pp, sizeof(__pyx_k_std_tlen_pp), 0, 0, 1, 1},
  {&__pyx_n_s_std_tlen_pp_fwd, __pyx_k_std_tlen_pp_fwd, sizeof(__pyx_k_std_tlen_pp_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_std_tlen_pp_rev, __pyx_k_std_tlen_pp_rev, sizeof(__pyx_k_std_tlen_pp_rev), 0, 0, 1, 1},
  {&__pyx_n_s_std_tlen_rev, __pyx_k_std_tlen_rev, sizeof(__pyx_k_std_tlen_rev), 0, 0, 1, 1},
  {&__pyx_n_s_string_types, __pyx_k_string_types, sizeof(__pyx_k_string_types), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_sys_2, __pyx_k_sys_2, sizeof(__pyx_k_sys_2), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_total, __pyx_k_total, sizeof(__pyx_k_total), 0, 0, 1, 1},
  {&__pyx_n_s_truncate, __pyx_k_truncate, sizeof(__pyx_k_truncate), 0, 0, 1, 1},
  {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
  {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
  {&__pyx_n_s_window_offset, __pyx_k_window_offset, sizeof(__pyx_k_window_offset), 0, 0, 1, 1},
  {&__pyx_n_s_window_size, __pyx_k_window_size, sizeof(__pyx_k_window_size), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_round = __Pyx_GetBuiltinName(__pyx_n_s_round); if (!__pyx_builtin_round) __PYX_ERR(0, 714, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 1534, __pyx_L1_error)
  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 107, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "pysamstats/opt.pyx":1532
 *     n = len(ref_window)
 *     if not PY2:
 *         ref_window = ref_window.encode('ascii')             # <<<<<<<<<<<<<<
 *     seq = ref_window
 *     for i in range(n):
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "pysamstats/opt.pyx":1990
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 *         if not PY2:
 *             refbase = refbase.encode('ascii')             # <<<<<<<<<<<<<<
 *     else:
 *         refbase = None
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 1990, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "pysamstats/opt.pyx":2111
 * 
 *     if chrom is None:
 *         return None, None             # <<<<<<<<<<<<<<
 * 
 *     else:
 */
  __pyx_tuple__4 = PyTuple_Pack(2, Py_None, Py_None); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 2111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "pysamstats/opt.pyx":1826
 * 
 * 
 * def iter_pileup(stat, alignmentfile, fafile, pad, **kwargs):             # <<<<<<<<<<<<<<
 *     """General purpose function to generate statistics, where one record is
 *     generated for each genome position in the selected range, based on a
 */
  __pyx_tuple__5 = PyTuple_Pack(5, __pyx_n_s_stat, __pyx_n_s_alignmentfile, __pyx_n_s_fafile, __pyx_n_s_pad, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 1826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);
  __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(4, 0, 5, 0, CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_iter_pileup, 1826, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 1826, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1845
 * 
 * 
 * def iter_pileup_default(stat, alignmentfile, fafile, chrom, start, end, one_based, truncate,             # <<<<<<<<<<<<<<
 *                         max_depth, int min_mapq, int min_baseq, bint no_del, bint no_dup):
 *     cdef:
 */
  __pyx_tuple__7 = PyTuple_Pack(16, __pyx_n_s_stat, __pyx_n_s_alignmentfile, __pyx_n_s_fafile, __pyx_n_s_chrom, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_one_based, __pyx_n_s_truncate, __pyx_n_s_max_depth, __pyx_n_s_min_mapq, __pyx_n_s_min_baseq, __pyx_n_s_no_del, __pyx_n_s_no_dup, __pyx_n_s_col, __pyx_n_s_it, __pyx_n_s_rec); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 1845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);
  __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(13, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_iter_pileup_default, 1845, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 1845, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1865
 * 
 * 
 * def stat_pileup(PileupStat stat,             # <<<<<<<<<<<<<<
 *                 PileupColumn col,
 *                 AlignmentFile alignmentfile,
 */
  __pyx_tuple__9 = PyTuple_Pack(18, __pyx_n_s_stat, __pyx_n_s_col, __pyx_n_s_alignmentfile, __pyx_n_s_fafile, __pyx_n_s_one_based, __pyx_n_s_min_mapq, __pyx_n_s_min_baseq, __pyx_n_s_no_del, __pyx_n_s_no_dup, __pyx_n_s_plp, __pyx_n_s_read, __pyx_n_s_b, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_chrom, __pyx_n_s_refbase, __pyx_n_s_rec, __pyx_n_s_pos); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 1865, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);
  __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(9, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_stat_pileup, 1865, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 1865, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1921
 * 
 * 
 * def iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs):             # <<<<<<<<<<<<<<
 *     if chrom is not None:
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 */
  __pyx_tuple__11 = PyTuple_Pack(8, __pyx_n_s_stat, __pyx_n_s_alignmentfile, __pyx_n_s_fafile, __pyx_n_s_chrom, __pyx_n_s_kwargs, __pyx_n_s_it, __pyx_n_s_its, __pyx_n_s_itc); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 1921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);
  __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_iter_pileup_padded, 1921, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 1921, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1935
 * 
 * 
 * def iter_pileup_padded_chrom(PileupStat stat, alignmentfile, fafile, chrom, start, end,             # <<<<<<<<<<<<<<
 *                              one_based, truncate, max_depth, min_mapq, min_baseq, no_del, no_dup):
 *     cdef:
 */
  __pyx_tuple__13 = PyTuple_Pack(19, __pyx_n_s_stat, __pyx_n_s_alignmentfile, __pyx_n_s_fafile, __pyx_n_s_chrom, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_one_based, __pyx_n_s_truncate, __pyx_n_s_max_depth, __pyx_n_s_min_mapq, __pyx_n_s_min_baseq, __pyx_n_s_no_del, __pyx_n_s_no_dup, __pyx_n_s_col, __pyx_n_s_curpos, __pyx_n_s_it, __pyx_n_s_refbase, __pyx_n_s_rec, __pyx_n_s_pos); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 1935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);
  __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(13, 0, 19, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_iter_pileup_padded_chrom, 1935, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 1935, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1986
 * 
 * 
 * def get_refbase(fafile, chrom, pos):             # <<<<<<<<<<<<<<
 *     if fafile is not None:
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 */
  __pyx_tuple__15 = PyTuple_Pack(4, __pyx_n_s_fafile, __pyx_n_s_chrom, __pyx_n_s_pos, __pyx_n_s_refbase); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 1986, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);
  __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_get_refbase, 1986, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 1986, __pyx_L1_error)

  /* "pysamstats/opt.pyx":1996
 * 
 * 
 * def iter_binned(stat, alignmentfile, fafile, chrom, window_size=300, window_offset=None,             # <<<<<<<<<<<<<<
 *                 **kwargs):
 * 
 */
  __pyx_tuple__17 = PyTuple_Pack(10, __pyx_n_s_stat, __pyx_n_s_alignmentfile, __pyx_n_s_fafile, __pyx_n_s_chrom, __pyx_n_s_window_size, __pyx_n_s_window_offset, __pyx_n_s_kwargs, __pyx_n_s_its, __pyx_n_s_itc, __pyx_n_s_it); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);
  __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(6, 0, 10, 0, CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_iter_binned, 1996, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 1996, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2025
 * 
 * 
 * def iter_binned_chrom(BinnedStat stat, AlignmentFile alignmentfile, FastaFile fafile,             # <<<<<<<<<<<<<<
 *                       chrom, start, end, one_based, int window_size, int window_offset,
 *                       int min_mapq, int no_dup):
 */
  __pyx_tuple__19 = PyTuple_Pack(21, __pyx_n_s_stat, __pyx_n_s_alignmentfile, __pyx_n_s_fafile, __pyx_n_s_chrom, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_one_based, __pyx_n_s_window_size, __pyx_n_s_window_offset, __pyx_n_s_min_mapq, __pyx_n_s_no_dup, __pyx_n_s_rtid, __pyx_n_s_rstart, __pyx_n_s_rend, __pyx_n_s_has_coord, __pyx_n_s_bin_start, __pyx_n_s_bin_end, __pyx_n_s_it, __pyx_n_s_b, __pyx_n_s_rec, __pyx_n_s_pos); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 2025, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);
  __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(11, 0, 21, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_iter_binned_chrom, 2025, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 2025, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2104
 * 
 * 
 * def normalise_coords(AlignmentFile alignmentfile, chrom, start, end, one_based):             # <<<<<<<<<<<<<<
 *     """Convert to zero-based coordinates and deal with unspecified start
 *     and/or end.
 */
  __pyx_tuple__21 = PyTuple_Pack(6, __pyx_n_s_alignmentfile, __pyx_n_s_chrom, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_one_based, __pyx_n_s_chrlen); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 2104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);
  __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_normalise_coords, 2104, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 2104, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2158
 * 
 * 
 * def rootmean(uint64_t sqsum, int count):             # <<<<<<<<<<<<<<
 *     if count > 0:
 *         return int(round(sqrt(sqsum / count)))
 */
  __pyx_tuple__23 = PyTuple_Pack(2, __pyx_n_s_sqsum, __pyx_n_s_count); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 2158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);
  __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_rootmean, 2158, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 2158, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2165
 * 
 * 
 * def mean(int64_t total, int count):             # <<<<<<<<<<<<<<
 *     if count > 0:
 *         return int(round(total / count))
 */
  __pyx_tuple__25 = PyTuple_Pack(2, __pyx_n_s_total, __pyx_n_s_count); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 2165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);
  __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_mean, 2165, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 2165, __pyx_L1_error)

  /* "pysamstats/opt.pyx":2175
 * 
 * 
 * def count_reads(AlignmentFile alignmentfile, chrom=None, start=None, end=None):             # <<<<<<<<<<<<<<
 *     cdef IteratorRowRegion it
 *     cdef int n = 0
 */
  __pyx_tuple__27 = PyTuple_Pack(10, __pyx_n_s_alignmentfile, __pyx_n_s_chrom, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_it, __pyx_n_s_n, __pyx_n_s_has_coord, __pyx_n_s_rtid, __pyx_n_s_rstart, __pyx_n_s_rend); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 2175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(4, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_aliman_src_github_alimanfo, __pyx_n_s_count_reads, 2175, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 2175, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_300 = PyInt_FromLong(300); if (unlikely(!__pyx_int_300)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initopt(void); /*proto*/
PyMODINIT_FUNC initopt(void)
#else
PyMODINIT_FUNC PyInit_opt(void); /*proto*/
PyMODINIT_FUNC PyInit_opt(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __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_opt(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __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("opt", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __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_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_pysamstats__opt) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "pysamstats.opt")) {
      if (unlikely(PyDict_SetItemString(modules, "pysamstats.opt", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_10pysamstats_3opt_PileupStat = &__pyx_vtable_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_PileupStat.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_10PileupStat_rec;
  __pyx_vtable_10pysamstats_3opt_PileupStat.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_10PileupStat_recv;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_PileupStat) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_PileupStat.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_PileupStat.tp_dict, __pyx_vtabptr_10pysamstats_3opt_PileupStat) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "PileupStat", (PyObject *)&__pyx_type_10pysamstats_3opt_PileupStat) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_PileupStat = &__pyx_type_10pysamstats_3opt_PileupStat;
  __pyx_vtabptr_10pysamstats_3opt_CountPp = &__pyx_vtable_10pysamstats_3opt_CountPp;
  __pyx_vtable_10pysamstats_3opt_CountPp.incr = (void (*)(struct __pyx_obj_10pysamstats_3opt_CountPp *, int))__pyx_f_10pysamstats_3opt_7CountPp_incr;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CountPp) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CountPp.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CountPp.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CountPp) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CountPp", (PyObject *)&__pyx_type_10pysamstats_3opt_CountPp) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CountPp = &__pyx_type_10pysamstats_3opt_CountPp;
  __pyx_vtabptr_10pysamstats_3opt_Coverage = &__pyx_vtable_10pysamstats_3opt_Coverage;
  __pyx_vtable_10pysamstats_3opt_Coverage.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_Coverage.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_8Coverage_rec;
  __pyx_vtable_10pysamstats_3opt_Coverage.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_8Coverage_recv;
  __pyx_type_10pysamstats_3opt_Coverage.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_Coverage) < 0) __PYX_ERR(0, 106, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_Coverage.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_Coverage.tp_dict, __pyx_vtabptr_10pysamstats_3opt_Coverage) < 0) __PYX_ERR(0, 106, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Coverage", (PyObject *)&__pyx_type_10pysamstats_3opt_Coverage) < 0) __PYX_ERR(0, 106, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_Coverage = &__pyx_type_10pysamstats_3opt_Coverage;
  __pyx_vtabptr_10pysamstats_3opt_CountPpStrand = &__pyx_vtable_10pysamstats_3opt_CountPpStrand;
  __pyx_vtable_10pysamstats_3opt_CountPpStrand.incr = (void (*)(struct __pyx_obj_10pysamstats_3opt_CountPpStrand *, int, int))__pyx_f_10pysamstats_3opt_13CountPpStrand_incr;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CountPpStrand) < 0) __PYX_ERR(0, 146, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CountPpStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CountPpStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CountPpStrand) < 0) __PYX_ERR(0, 146, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CountPpStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_CountPpStrand) < 0) __PYX_ERR(0, 146, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CountPpStrand = &__pyx_type_10pysamstats_3opt_CountPpStrand;
  __pyx_vtabptr_10pysamstats_3opt_CoverageStrand = &__pyx_vtable_10pysamstats_3opt_CoverageStrand;
  __pyx_vtable_10pysamstats_3opt_CoverageStrand.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_CoverageStrand.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_14CoverageStrand_rec;
  __pyx_vtable_10pysamstats_3opt_CoverageStrand.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_14CoverageStrand_recv;
  __pyx_type_10pysamstats_3opt_CoverageStrand.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CoverageStrand) < 0) __PYX_ERR(0, 171, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CoverageStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CoverageStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CoverageStrand) < 0) __PYX_ERR(0, 171, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CoverageStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_CoverageStrand) < 0) __PYX_ERR(0, 171, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CoverageStrand = &__pyx_type_10pysamstats_3opt_CoverageStrand;
  __pyx_vtabptr_10pysamstats_3opt_CoverageExt = &__pyx_vtable_10pysamstats_3opt_CoverageExt;
  __pyx_vtable_10pysamstats_3opt_CoverageExt.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_CoverageExt.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_11CoverageExt_rec;
  __pyx_vtable_10pysamstats_3opt_CoverageExt.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_11CoverageExt_recv;
  __pyx_type_10pysamstats_3opt_CoverageExt.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CoverageExt) < 0) __PYX_ERR(0, 219, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CoverageExt.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CoverageExt.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CoverageExt) < 0) __PYX_ERR(0, 219, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CoverageExt", (PyObject *)&__pyx_type_10pysamstats_3opt_CoverageExt) < 0) __PYX_ERR(0, 219, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CoverageExt = &__pyx_type_10pysamstats_3opt_CoverageExt;
  __pyx_vtabptr_10pysamstats_3opt_CountStrand = &__pyx_vtable_10pysamstats_3opt_CountStrand;
  __pyx_vtable_10pysamstats_3opt_CountStrand.incr = (void (*)(struct __pyx_obj_10pysamstats_3opt_CountStrand *, int))__pyx_f_10pysamstats_3opt_11CountStrand_incr;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CountStrand) < 0) __PYX_ERR(0, 304, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CountStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CountStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CountStrand) < 0) __PYX_ERR(0, 304, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CountStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_CountStrand) < 0) __PYX_ERR(0, 304, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CountStrand = &__pyx_type_10pysamstats_3opt_CountStrand;
  __pyx_vtabptr_10pysamstats_3opt_CoverageExtStrand = &__pyx_vtable_10pysamstats_3opt_CoverageExtStrand;
  __pyx_vtable_10pysamstats_3opt_CoverageExtStrand.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_CoverageExtStrand.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_17CoverageExtStrand_rec;
  __pyx_vtable_10pysamstats_3opt_CoverageExtStrand.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_17CoverageExtStrand_recv;
  __pyx_type_10pysamstats_3opt_CoverageExtStrand.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CoverageExtStrand) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CoverageExtStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CoverageExtStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CoverageExtStrand) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CoverageExtStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_CoverageExtStrand) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CoverageExtStrand = &__pyx_type_10pysamstats_3opt_CoverageExtStrand;
  __pyx_vtabptr_10pysamstats_3opt_Variation = &__pyx_vtable_10pysamstats_3opt_Variation;
  __pyx_vtable_10pysamstats_3opt_Variation.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_Variation.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_9Variation_rec;
  __pyx_vtable_10pysamstats_3opt_Variation.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_9Variation_recv;
  __pyx_type_10pysamstats_3opt_Variation.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_Variation) < 0) __PYX_ERR(0, 434, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_Variation.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_Variation.tp_dict, __pyx_vtabptr_10pysamstats_3opt_Variation) < 0) __PYX_ERR(0, 434, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Variation", (PyObject *)&__pyx_type_10pysamstats_3opt_Variation) < 0) __PYX_ERR(0, 434, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_Variation = &__pyx_type_10pysamstats_3opt_Variation;
  __pyx_vtabptr_10pysamstats_3opt_VariationStrand = &__pyx_vtable_10pysamstats_3opt_VariationStrand;
  __pyx_vtable_10pysamstats_3opt_VariationStrand.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_VariationStrand.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_15VariationStrand_rec;
  __pyx_vtable_10pysamstats_3opt_VariationStrand.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_15VariationStrand_recv;
  __pyx_type_10pysamstats_3opt_VariationStrand.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_VariationStrand) < 0) __PYX_ERR(0, 543, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_VariationStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_VariationStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_VariationStrand) < 0) __PYX_ERR(0, 543, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "VariationStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_VariationStrand) < 0) __PYX_ERR(0, 543, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_VariationStrand = &__pyx_type_10pysamstats_3opt_VariationStrand;
  __pyx_vtabptr_10pysamstats_3opt_TlenHelper = &__pyx_vtable_10pysamstats_3opt_TlenHelper;
  __pyx_vtable_10pysamstats_3opt_TlenHelper.update = (void (*)(struct __pyx_obj_10pysamstats_3opt_TlenHelper *, int64_t))__pyx_f_10pysamstats_3opt_10TlenHelper_update;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_TlenHelper) < 0) __PYX_ERR(0, 678, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_TlenHelper.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_TlenHelper.tp_dict, __pyx_vtabptr_10pysamstats_3opt_TlenHelper) < 0) __PYX_ERR(0, 678, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "TlenHelper", (PyObject *)&__pyx_type_10pysamstats_3opt_TlenHelper) < 0) __PYX_ERR(0, 678, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_TlenHelper = &__pyx_type_10pysamstats_3opt_TlenHelper;
  __pyx_vtabptr_10pysamstats_3opt_Tlen = &__pyx_vtable_10pysamstats_3opt_Tlen;
  __pyx_vtable_10pysamstats_3opt_Tlen.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_Tlen.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_4Tlen_rec;
  __pyx_vtable_10pysamstats_3opt_Tlen.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_4Tlen_recv;
  __pyx_type_10pysamstats_3opt_Tlen.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_Tlen) < 0) __PYX_ERR(0, 730, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_Tlen.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_Tlen.tp_dict, __pyx_vtabptr_10pysamstats_3opt_Tlen) < 0) __PYX_ERR(0, 730, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Tlen", (PyObject *)&__pyx_type_10pysamstats_3opt_Tlen) < 0) __PYX_ERR(0, 730, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_Tlen = &__pyx_type_10pysamstats_3opt_Tlen;
  __pyx_vtabptr_10pysamstats_3opt_TlenStrand = &__pyx_vtable_10pysamstats_3opt_TlenStrand;
  __pyx_vtable_10pysamstats_3opt_TlenStrand.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_TlenStrand.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_10TlenStrand_rec;
  __pyx_vtable_10pysamstats_3opt_TlenStrand.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_10TlenStrand_recv;
  __pyx_type_10pysamstats_3opt_TlenStrand.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_TlenStrand) < 0) __PYX_ERR(0, 795, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_TlenStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_TlenStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_TlenStrand) < 0) __PYX_ERR(0, 795, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "TlenStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_TlenStrand) < 0) __PYX_ERR(0, 795, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_TlenStrand = &__pyx_type_10pysamstats_3opt_TlenStrand;
  __pyx_vtabptr_10pysamstats_3opt_MapqHelper = &__pyx_vtable_10pysamstats_3opt_MapqHelper;
  __pyx_vtable_10pysamstats_3opt_MapqHelper.update = (void (*)(struct __pyx_obj_10pysamstats_3opt_MapqHelper *, uint64_t))__pyx_f_10pysamstats_3opt_10MapqHelper_update;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_MapqHelper) < 0) __PYX_ERR(0, 911, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_MapqHelper.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_MapqHelper.tp_dict, __pyx_vtabptr_10pysamstats_3opt_MapqHelper) < 0) __PYX_ERR(0, 911, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "MapqHelper", (PyObject *)&__pyx_type_10pysamstats_3opt_MapqHelper) < 0) __PYX_ERR(0, 911, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_MapqHelper = &__pyx_type_10pysamstats_3opt_MapqHelper;
  __pyx_vtabptr_10pysamstats_3opt_Mapq = &__pyx_vtable_10pysamstats_3opt_Mapq;
  __pyx_vtable_10pysamstats_3opt_Mapq.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_Mapq.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_4Mapq_rec;
  __pyx_vtable_10pysamstats_3opt_Mapq.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_4Mapq_recv;
  __pyx_type_10pysamstats_3opt_Mapq.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_Mapq) < 0) __PYX_ERR(0, 940, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_Mapq.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_Mapq.tp_dict, __pyx_vtabptr_10pysamstats_3opt_Mapq) < 0) __PYX_ERR(0, 940, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Mapq", (PyObject *)&__pyx_type_10pysamstats_3opt_Mapq) < 0) __PYX_ERR(0, 940, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_Mapq = &__pyx_type_10pysamstats_3opt_Mapq;
  __pyx_vtabptr_10pysamstats_3opt_MapqStrand = &__pyx_vtable_10pysamstats_3opt_MapqStrand;
  __pyx_vtable_10pysamstats_3opt_MapqStrand.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_MapqStrand.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_10MapqStrand_rec;
  __pyx_vtable_10pysamstats_3opt_MapqStrand.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_10MapqStrand_recv;
  __pyx_type_10pysamstats_3opt_MapqStrand.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_MapqStrand) < 0) __PYX_ERR(0, 996, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_MapqStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_MapqStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_MapqStrand) < 0) __PYX_ERR(0, 996, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "MapqStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_MapqStrand) < 0) __PYX_ERR(0, 996, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_MapqStrand = &__pyx_type_10pysamstats_3opt_MapqStrand;
  __pyx_vtabptr_10pysamstats_3opt_BaseqHelper = &__pyx_vtable_10pysamstats_3opt_BaseqHelper;
  __pyx_vtable_10pysamstats_3opt_BaseqHelper.update = (void (*)(struct __pyx_obj_10pysamstats_3opt_BaseqHelper *, int64_t))__pyx_f_10pysamstats_3opt_11BaseqHelper_update;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_BaseqHelper) < 0) __PYX_ERR(0, 1092, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_BaseqHelper.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_BaseqHelper.tp_dict, __pyx_vtabptr_10pysamstats_3opt_BaseqHelper) < 0) __PYX_ERR(0, 1092, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "BaseqHelper", (PyObject *)&__pyx_type_10pysamstats_3opt_BaseqHelper) < 0) __PYX_ERR(0, 1092, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_BaseqHelper = &__pyx_type_10pysamstats_3opt_BaseqHelper;
  __pyx_vtabptr_10pysamstats_3opt_BaseqPpHelper = &__pyx_vtable_10pysamstats_3opt_BaseqPpHelper;
  __pyx_vtable_10pysamstats_3opt_BaseqPpHelper.update = (void (*)(struct __pyx_obj_10pysamstats_3opt_BaseqPpHelper *, int64_t, int))__pyx_f_10pysamstats_3opt_13BaseqPpHelper_update;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_BaseqPpHelper) < 0) __PYX_ERR(0, 1118, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_BaseqPpHelper.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_BaseqPpHelper.tp_dict, __pyx_vtabptr_10pysamstats_3opt_BaseqPpHelper) < 0) __PYX_ERR(0, 1118, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "BaseqPpHelper", (PyObject *)&__pyx_type_10pysamstats_3opt_BaseqPpHelper) < 0) __PYX_ERR(0, 1118, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_BaseqPpHelper = &__pyx_type_10pysamstats_3opt_BaseqPpHelper;
  __pyx_vtabptr_10pysamstats_3opt_Baseq = &__pyx_vtable_10pysamstats_3opt_Baseq;
  __pyx_vtable_10pysamstats_3opt_Baseq.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_Baseq.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_5Baseq_rec;
  __pyx_vtable_10pysamstats_3opt_Baseq.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_5Baseq_recv;
  __pyx_type_10pysamstats_3opt_Baseq.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_Baseq) < 0) __PYX_ERR(0, 1140, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_Baseq.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_Baseq.tp_dict, __pyx_vtabptr_10pysamstats_3opt_Baseq) < 0) __PYX_ERR(0, 1140, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "Baseq", (PyObject *)&__pyx_type_10pysamstats_3opt_Baseq) < 0) __PYX_ERR(0, 1140, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_Baseq = &__pyx_type_10pysamstats_3opt_Baseq;
  __pyx_vtabptr_10pysamstats_3opt_BaseqStrandPpHelper = &__pyx_vtable_10pysamstats_3opt_BaseqStrandPpHelper;
  __pyx_vtable_10pysamstats_3opt_BaseqStrandPpHelper.update = (void (*)(struct __pyx_obj_10pysamstats_3opt_BaseqStrandPpHelper *, int64_t, int, int))__pyx_f_10pysamstats_3opt_19BaseqStrandPpHelper_update;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_BaseqStrandPpHelper) < 0) __PYX_ERR(0, 1187, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_BaseqStrandPpHelper.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_BaseqStrandPpHelper.tp_dict, __pyx_vtabptr_10pysamstats_3opt_BaseqStrandPpHelper) < 0) __PYX_ERR(0, 1187, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "BaseqStrandPpHelper", (PyObject *)&__pyx_type_10pysamstats_3opt_BaseqStrandPpHelper) < 0) __PYX_ERR(0, 1187, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_BaseqStrandPpHelper = &__pyx_type_10pysamstats_3opt_BaseqStrandPpHelper;
  __pyx_vtabptr_10pysamstats_3opt_BaseqStrand = &__pyx_vtable_10pysamstats_3opt_BaseqStrand;
  __pyx_vtable_10pysamstats_3opt_BaseqStrand.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_BaseqStrand.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_11BaseqStrand_rec;
  __pyx_vtable_10pysamstats_3opt_BaseqStrand.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_11BaseqStrand_recv;
  __pyx_type_10pysamstats_3opt_BaseqStrand.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_BaseqStrand) < 0) __PYX_ERR(0, 1229, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_BaseqStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_BaseqStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_BaseqStrand) < 0) __PYX_ERR(0, 1229, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "BaseqStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_BaseqStrand) < 0) __PYX_ERR(0, 1229, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_BaseqStrand = &__pyx_type_10pysamstats_3opt_BaseqStrand;
  __pyx_vtabptr_10pysamstats_3opt_BaseqExt = &__pyx_vtable_10pysamstats_3opt_BaseqExt;
  __pyx_vtable_10pysamstats_3opt_BaseqExt.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_BaseqExt.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_8BaseqExt_rec;
  __pyx_vtable_10pysamstats_3opt_BaseqExt.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_8BaseqExt_recv;
  __pyx_type_10pysamstats_3opt_BaseqExt.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_BaseqExt) < 0) __PYX_ERR(0, 1291, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_BaseqExt.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_BaseqExt.tp_dict, __pyx_vtabptr_10pysamstats_3opt_BaseqExt) < 0) __PYX_ERR(0, 1291, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "BaseqExt", (PyObject *)&__pyx_type_10pysamstats_3opt_BaseqExt) < 0) __PYX_ERR(0, 1291, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_BaseqExt = &__pyx_type_10pysamstats_3opt_BaseqExt;
  __pyx_vtabptr_10pysamstats_3opt_BaseqExtStrand = &__pyx_vtable_10pysamstats_3opt_BaseqExtStrand;
  __pyx_vtable_10pysamstats_3opt_BaseqExtStrand.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_BaseqExtStrand.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_14BaseqExtStrand_rec;
  __pyx_vtable_10pysamstats_3opt_BaseqExtStrand.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_14BaseqExtStrand_recv;
  __pyx_type_10pysamstats_3opt_BaseqExtStrand.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_BaseqExtStrand) < 0) __PYX_ERR(0, 1366, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_BaseqExtStrand.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_BaseqExtStrand.tp_dict, __pyx_vtabptr_10pysamstats_3opt_BaseqExtStrand) < 0) __PYX_ERR(0, 1366, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "BaseqExtStrand", (PyObject *)&__pyx_type_10pysamstats_3opt_BaseqExtStrand) < 0) __PYX_ERR(0, 1366, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_BaseqExtStrand = &__pyx_type_10pysamstats_3opt_BaseqExtStrand;
  __pyx_vtabptr_10pysamstats_3opt_CoverageGC = &__pyx_vtable_10pysamstats_3opt_CoverageGC;
  __pyx_vtable_10pysamstats_3opt_CoverageGC.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_PileupStat;
  __pyx_vtable_10pysamstats_3opt_CoverageGC.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *, PyObject *))__pyx_f_10pysamstats_3opt_10CoverageGC_rec;
  __pyx_vtable_10pysamstats_3opt_CoverageGC.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_PileupStat *, bam_pileup1_t *, struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn *, PyObject *))__pyx_f_10pysamstats_3opt_10CoverageGC_recv;
  __pyx_type_10pysamstats_3opt_CoverageGC.tp_base = __pyx_ptype_10pysamstats_3opt_PileupStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CoverageGC) < 0) __PYX_ERR(0, 1470, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CoverageGC.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CoverageGC.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CoverageGC) < 0) __PYX_ERR(0, 1470, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CoverageGC", (PyObject *)&__pyx_type_10pysamstats_3opt_CoverageGC) < 0) __PYX_ERR(0, 1470, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CoverageGC = &__pyx_type_10pysamstats_3opt_CoverageGC;
  __pyx_vtabptr_10pysamstats_3opt_BinnedStat = &__pyx_vtable_10pysamstats_3opt_BinnedStat;
  __pyx_vtable_10pysamstats_3opt_BinnedStat.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *))__pyx_f_10pysamstats_3opt_10BinnedStat_rec;
  __pyx_vtable_10pysamstats_3opt_BinnedStat.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, bam1_t *))__pyx_f_10pysamstats_3opt_10BinnedStat_recv;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_BinnedStat) < 0) __PYX_ERR(0, 1541, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_BinnedStat.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_BinnedStat.tp_dict, __pyx_vtabptr_10pysamstats_3opt_BinnedStat) < 0) __PYX_ERR(0, 1541, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "BinnedStat", (PyObject *)&__pyx_type_10pysamstats_3opt_BinnedStat) < 0) __PYX_ERR(0, 1541, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_BinnedStat = &__pyx_type_10pysamstats_3opt_BinnedStat;
  __pyx_vtabptr_10pysamstats_3opt_CoverageBinned = &__pyx_vtable_10pysamstats_3opt_CoverageBinned;
  __pyx_vtable_10pysamstats_3opt_CoverageBinned.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_BinnedStat;
  __pyx_vtable_10pysamstats_3opt_CoverageBinned.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *))__pyx_f_10pysamstats_3opt_14CoverageBinned_rec;
  __pyx_vtable_10pysamstats_3opt_CoverageBinned.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, bam1_t *))__pyx_f_10pysamstats_3opt_14CoverageBinned_recv;
  __pyx_type_10pysamstats_3opt_CoverageBinned.tp_base = __pyx_ptype_10pysamstats_3opt_BinnedStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CoverageBinned) < 0) __PYX_ERR(0, 1550, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CoverageBinned.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CoverageBinned.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CoverageBinned) < 0) __PYX_ERR(0, 1550, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CoverageBinned", (PyObject *)&__pyx_type_10pysamstats_3opt_CoverageBinned) < 0) __PYX_ERR(0, 1550, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CoverageBinned = &__pyx_type_10pysamstats_3opt_CoverageBinned;
  __pyx_vtabptr_10pysamstats_3opt_CoverageExtBinned = &__pyx_vtable_10pysamstats_3opt_CoverageExtBinned;
  __pyx_vtable_10pysamstats_3opt_CoverageExtBinned.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_BinnedStat;
  __pyx_vtable_10pysamstats_3opt_CoverageExtBinned.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *))__pyx_f_10pysamstats_3opt_17CoverageExtBinned_rec;
  __pyx_vtable_10pysamstats_3opt_CoverageExtBinned.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, bam1_t *))__pyx_f_10pysamstats_3opt_17CoverageExtBinned_recv;
  __pyx_type_10pysamstats_3opt_CoverageExtBinned.tp_base = __pyx_ptype_10pysamstats_3opt_BinnedStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_CoverageExtBinned) < 0) __PYX_ERR(0, 1591, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_CoverageExtBinned.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_CoverageExtBinned.tp_dict, __pyx_vtabptr_10pysamstats_3opt_CoverageExtBinned) < 0) __PYX_ERR(0, 1591, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "CoverageExtBinned", (PyObject *)&__pyx_type_10pysamstats_3opt_CoverageExtBinned) < 0) __PYX_ERR(0, 1591, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_CoverageExtBinned = &__pyx_type_10pysamstats_3opt_CoverageExtBinned;
  __pyx_vtabptr_10pysamstats_3opt_MapqBinned = &__pyx_vtable_10pysamstats_3opt_MapqBinned;
  __pyx_vtable_10pysamstats_3opt_MapqBinned.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_BinnedStat;
  __pyx_vtable_10pysamstats_3opt_MapqBinned.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *))__pyx_f_10pysamstats_3opt_10MapqBinned_rec;
  __pyx_vtable_10pysamstats_3opt_MapqBinned.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, bam1_t *))__pyx_f_10pysamstats_3opt_10MapqBinned_recv;
  __pyx_type_10pysamstats_3opt_MapqBinned.tp_base = __pyx_ptype_10pysamstats_3opt_BinnedStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_MapqBinned) < 0) __PYX_ERR(0, 1669, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_MapqBinned.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_MapqBinned.tp_dict, __pyx_vtabptr_10pysamstats_3opt_MapqBinned) < 0) __PYX_ERR(0, 1669, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "MapqBinned", (PyObject *)&__pyx_type_10pysamstats_3opt_MapqBinned) < 0) __PYX_ERR(0, 1669, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_MapqBinned = &__pyx_type_10pysamstats_3opt_MapqBinned;
  __pyx_vtabptr_10pysamstats_3opt_AlignmentBinned = &__pyx_vtable_10pysamstats_3opt_AlignmentBinned;
  __pyx_vtable_10pysamstats_3opt_AlignmentBinned.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_BinnedStat;
  __pyx_vtable_10pysamstats_3opt_AlignmentBinned.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *))__pyx_f_10pysamstats_3opt_15AlignmentBinned_rec;
  __pyx_vtable_10pysamstats_3opt_AlignmentBinned.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, bam1_t *))__pyx_f_10pysamstats_3opt_15AlignmentBinned_recv;
  __pyx_type_10pysamstats_3opt_AlignmentBinned.tp_base = __pyx_ptype_10pysamstats_3opt_BinnedStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_AlignmentBinned) < 0) __PYX_ERR(0, 1710, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_AlignmentBinned.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_AlignmentBinned.tp_dict, __pyx_vtabptr_10pysamstats_3opt_AlignmentBinned) < 0) __PYX_ERR(0, 1710, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "AlignmentBinned", (PyObject *)&__pyx_type_10pysamstats_3opt_AlignmentBinned) < 0) __PYX_ERR(0, 1710, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_AlignmentBinned = &__pyx_type_10pysamstats_3opt_AlignmentBinned;
  __pyx_vtabptr_10pysamstats_3opt_TlenBinned = &__pyx_vtable_10pysamstats_3opt_TlenBinned;
  __pyx_vtable_10pysamstats_3opt_TlenBinned.__pyx_base = *__pyx_vtabptr_10pysamstats_3opt_BinnedStat;
  __pyx_vtable_10pysamstats_3opt_TlenBinned.__pyx_base.rec = (PyObject *(*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_5pysam_9libcfaidx_FastaFile *))__pyx_f_10pysamstats_3opt_10TlenBinned_rec;
  __pyx_vtable_10pysamstats_3opt_TlenBinned.__pyx_base.recv = (void (*)(struct __pyx_obj_10pysamstats_3opt_BinnedStat *, bam1_t *))__pyx_f_10pysamstats_3opt_10TlenBinned_recv;
  __pyx_type_10pysamstats_3opt_TlenBinned.tp_base = __pyx_ptype_10pysamstats_3opt_BinnedStat;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt_TlenBinned) < 0) __PYX_ERR(0, 1771, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt_TlenBinned.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_10pysamstats_3opt_TlenBinned.tp_dict, __pyx_vtabptr_10pysamstats_3opt_TlenBinned) < 0) __PYX_ERR(0, 1771, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "TlenBinned", (PyObject *)&__pyx_type_10pysamstats_3opt_TlenBinned) < 0) __PYX_ERR(0, 1771, __pyx_L1_error)
  __pyx_ptype_10pysamstats_3opt_TlenBinned = &__pyx_type_10pysamstats_3opt_TlenBinned;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default) < 0) __PYX_ERR(0, 1845, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default.tp_print = 0;
  __pyx_ptype_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default = &__pyx_type_10pysamstats_3opt___pyx_scope_struct__iter_pileup_default;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom) < 0) __PYX_ERR(0, 1935, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom.tp_print = 0;
  __pyx_ptype_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom = &__pyx_type_10pysamstats_3opt___pyx_scope_struct_1_iter_pileup_padded_chrom;
  if (PyType_Ready(&__pyx_type_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom) < 0) __PYX_ERR(0, 2025, __pyx_L1_error)
  __pyx_type_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom.tp_print = 0;
  __pyx_ptype_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom = &__pyx_type_10pysamstats_3opt___pyx_scope_struct_2_iter_binned_chrom;
  /*--- 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_ERR(2, 9, __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_ERR(3, 8, __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_ERR(4, 15, __pyx_L1_error)
  __pyx_ptype_5pysam_10libchtslib_HTSFile = __Pyx_ImportType("pysam.libchtslib", "HTSFile", sizeof(struct __pyx_obj_5pysam_10libchtslib_HTSFile), 1); if (unlikely(!__pyx_ptype_5pysam_10libchtslib_HTSFile)) __PYX_ERR(5, 2563, __pyx_L1_error)
  __pyx_vtabptr_5pysam_10libchtslib_HTSFile = (struct __pyx_vtabstruct_5pysam_10libchtslib_HTSFile*)__Pyx_GetVtable(__pyx_ptype_5pysam_10libchtslib_HTSFile->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_10libchtslib_HTSFile)) __PYX_ERR(5, 2563, __pyx_L1_error)
  __pyx_ptype_7cpython_5array_array = __Pyx_ImportType("array", "array", sizeof(arrayobject), 0); if (unlikely(!__pyx_ptype_7cpython_5array_array)) __PYX_ERR(1, 58, __pyx_L1_error)
  __pyx_ptype_5pysam_9libcfaidx_FastaFile = __Pyx_ImportType("pysam.libcfaidx", "FastaFile", sizeof(struct __pyx_obj_5pysam_9libcfaidx_FastaFile), 1); if (unlikely(!__pyx_ptype_5pysam_9libcfaidx_FastaFile)) __PYX_ERR(6, 37, __pyx_L1_error)
  __pyx_vtabptr_5pysam_9libcfaidx_FastaFile = (struct __pyx_vtabstruct_5pysam_9libcfaidx_FastaFile*)__Pyx_GetVtable(__pyx_ptype_5pysam_9libcfaidx_FastaFile->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_9libcfaidx_FastaFile)) __PYX_ERR(6, 37, __pyx_L1_error)
  __pyx_ptype_5pysam_9libcfaidx_FastqProxy = __Pyx_ImportType("pysam.libcfaidx", "FastqProxy", sizeof(struct __pyx_obj_5pysam_9libcfaidx_FastqProxy), 1); if (unlikely(!__pyx_ptype_5pysam_9libcfaidx_FastqProxy)) __PYX_ERR(6, 45, __pyx_L1_error)
  __pyx_vtabptr_5pysam_9libcfaidx_FastqProxy = (struct __pyx_vtabstruct_5pysam_9libcfaidx_FastqProxy*)__Pyx_GetVtable(__pyx_ptype_5pysam_9libcfaidx_FastqProxy->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_9libcfaidx_FastqProxy)) __PYX_ERR(6, 45, __pyx_L1_error)
  __pyx_ptype_5pysam_9libcfaidx_PersistentFastqProxy = __Pyx_ImportType("pysam.libcfaidx", "PersistentFastqProxy", sizeof(struct __pyx_obj_5pysam_9libcfaidx_PersistentFastqProxy), 1); if (unlikely(!__pyx_ptype_5pysam_9libcfaidx_PersistentFastqProxy)) __PYX_ERR(6, 51, __pyx_L1_error)
  __pyx_vtabptr_5pysam_9libcfaidx_PersistentFastqProxy = (struct __pyx_vtabstruct_5pysam_9libcfaidx_PersistentFastqProxy*)__Pyx_GetVtable(__pyx_ptype_5pysam_9libcfaidx_PersistentFastqProxy->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_9libcfaidx_PersistentFastqProxy)) __PYX_ERR(6, 51, __pyx_L1_error)
  __pyx_ptype_5pysam_9libcfaidx_FastxFile = __Pyx_ImportType("pysam.libcfaidx", "FastxFile", sizeof(struct __pyx_obj_5pysam_9libcfaidx_FastxFile), 1); if (unlikely(!__pyx_ptype_5pysam_9libcfaidx_FastxFile)) __PYX_ERR(6, 60, __pyx_L1_error)
  __pyx_vtabptr_5pysam_9libcfaidx_FastxFile = (struct __pyx_vtabstruct_5pysam_9libcfaidx_FastxFile*)__Pyx_GetVtable(__pyx_ptype_5pysam_9libcfaidx_FastxFile->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_9libcfaidx_FastxFile)) __PYX_ERR(6, 60, __pyx_L1_error)
  __pyx_ptype_5pysam_9libcfaidx_FastqFile = __Pyx_ImportType("pysam.libcfaidx", "FastqFile", sizeof(struct __pyx_obj_5pysam_9libcfaidx_FastqFile), 1); if (unlikely(!__pyx_ptype_5pysam_9libcfaidx_FastqFile)) __PYX_ERR(6, 72, __pyx_L1_error)
  __pyx_vtabptr_5pysam_9libcfaidx_FastqFile = (struct __pyx_vtabstruct_5pysam_9libcfaidx_FastqFile*)__Pyx_GetVtable(__pyx_ptype_5pysam_9libcfaidx_FastqFile->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_9libcfaidx_FastqFile)) __PYX_ERR(6, 72, __pyx_L1_error)
  __pyx_ptype_5pysam_9libcfaidx_Fastafile = __Pyx_ImportType("pysam.libcfaidx", "Fastafile", sizeof(struct __pyx_obj_5pysam_9libcfaidx_Fastafile), 1); if (unlikely(!__pyx_ptype_5pysam_9libcfaidx_Fastafile)) __PYX_ERR(6, 77, __pyx_L1_error)
  __pyx_vtabptr_5pysam_9libcfaidx_Fastafile = (struct __pyx_vtabstruct_5pysam_9libcfaidx_Fastafile*)__Pyx_GetVtable(__pyx_ptype_5pysam_9libcfaidx_Fastafile->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_9libcfaidx_Fastafile)) __PYX_ERR(6, 77, __pyx_L1_error)
  __pyx_ptype_5pysam_18libcalignedsegment_AlignedSegment = __Pyx_ImportType("pysam.libcalignedsegment", "AlignedSegment", sizeof(struct __pyx_obj_5pysam_18libcalignedsegment_AlignedSegment), 1); if (unlikely(!__pyx_ptype_5pysam_18libcalignedsegment_AlignedSegment)) __PYX_ERR(7, 34, __pyx_L1_error)
  __pyx_vtabptr_5pysam_18libcalignedsegment_AlignedSegment = (struct __pyx_vtabstruct_5pysam_18libcalignedsegment_AlignedSegment*)__Pyx_GetVtable(__pyx_ptype_5pysam_18libcalignedsegment_AlignedSegment->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_18libcalignedsegment_AlignedSegment)) __PYX_ERR(7, 34, __pyx_L1_error)
  __pyx_ptype_5pysam_18libcalignedsegment_PileupColumn = __Pyx_ImportType("pysam.libcalignedsegment", "PileupColumn", sizeof(struct __pyx_obj_5pysam_18libcalignedsegment_PileupColumn), 1); if (unlikely(!__pyx_ptype_5pysam_18libcalignedsegment_PileupColumn)) __PYX_ERR(7, 63, __pyx_L1_error)
  __pyx_ptype_5pysam_18libcalignedsegment_PileupRead = __Pyx_ImportType("pysam.libcalignedsegment", "PileupRead", sizeof(struct __pyx_obj_5pysam_18libcalignedsegment_PileupRead), 1); if (unlikely(!__pyx_ptype_5pysam_18libcalignedsegment_PileupRead)) __PYX_ERR(7, 71, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile = __Pyx_ImportType("pysam.libcalignmentfile", "AlignmentFile", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_AlignmentFile), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile)) __PYX_ERR(8, 39, __pyx_L1_error)
  __pyx_vtabptr_5pysam_17libcalignmentfile_AlignmentFile = (struct __pyx_vtabstruct_5pysam_17libcalignmentfile_AlignmentFile*)__Pyx_GetVtable(__pyx_ptype_5pysam_17libcalignmentfile_AlignmentFile->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_17libcalignmentfile_AlignmentFile)) __PYX_ERR(8, 39, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_PileupColumn = __Pyx_ImportType("pysam.libcalignmentfile", "PileupColumn", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_PileupColumn), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_PileupColumn)) __PYX_ERR(8, 57, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_PileupRead = __Pyx_ImportType("pysam.libcalignmentfile", "PileupRead", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_PileupRead), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_PileupRead)) __PYX_ERR(8, 64, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorRow = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorRow", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRow), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorRow)) __PYX_ERR(8, 75, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorRowRegion = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorRowRegion", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowRegion), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowRegion)) __PYX_ERR(8, 84, __pyx_L1_error)
  __pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowRegion = (struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowRegion*)__Pyx_GetVtable(__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowRegion->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowRegion)) __PYX_ERR(8, 84, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorRowHead = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorRowHead", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowHead), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowHead)) __PYX_ERR(8, 89, __pyx_L1_error)
  __pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowHead = (struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowHead*)__Pyx_GetVtable(__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowHead->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowHead)) __PYX_ERR(8, 89, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorRowAll = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorRowAll", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowAll), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowAll)) __PYX_ERR(8, 95, __pyx_L1_error)
  __pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowAll = (struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowAll*)__Pyx_GetVtable(__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowAll->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowAll)) __PYX_ERR(8, 95, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorRowAllRefs = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorRowAllRefs", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowAllRefs), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowAllRefs)) __PYX_ERR(8, 100, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorRowSelection = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorRowSelection", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorRowSelection), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowSelection)) __PYX_ERR(8, 105, __pyx_L1_error)
  __pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowSelection = (struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorRowSelection*)__Pyx_GetVtable(__pyx_ptype_5pysam_17libcalignmentfile_IteratorRowSelection->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorRowSelection)) __PYX_ERR(8, 105, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorColumn = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorColumn", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumn), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumn)) __PYX_ERR(8, 112, __pyx_L1_error)
  __pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumn = (struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumn*)__Pyx_GetVtable(__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumn->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumn)) __PYX_ERR(8, 112, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorColumnRegion = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorColumnRegion", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumnRegion), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumnRegion)) __PYX_ERR(8, 141, __pyx_L1_error)
  __pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumnRegion = (struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumnRegion*)__Pyx_GetVtable(__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumnRegion->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumnRegion)) __PYX_ERR(8, 141, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IteratorColumnAllRefs = __Pyx_ImportType("pysam.libcalignmentfile", "IteratorColumnAllRefs", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IteratorColumnAllRefs), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumnAllRefs)) __PYX_ERR(8, 147, __pyx_L1_error)
  __pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumnAllRefs = (struct __pyx_vtabstruct_5pysam_17libcalignmentfile_IteratorColumnAllRefs*)__Pyx_GetVtable(__pyx_ptype_5pysam_17libcalignmentfile_IteratorColumnAllRefs->tp_dict); if (unlikely(!__pyx_vtabptr_5pysam_17libcalignmentfile_IteratorColumnAllRefs)) __PYX_ERR(8, 147, __pyx_L1_error)
  __pyx_ptype_5pysam_17libcalignmentfile_IndexedReads = __Pyx_ImportType("pysam.libcalignmentfile", "IndexedReads", sizeof(struct __pyx_obj_5pysam_17libcalignmentfile_IndexedReads), 1); if (unlikely(!__pyx_ptype_5pysam_17libcalignmentfile_IndexedReads)) __PYX_ERR(8, 151, __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_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "pysamstats/opt.pyx":16
 * 
 * 
 * import sys as _sys             # <<<<<<<<<<<<<<
 * import itertools
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys_2, __pyx_t_1) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":17
 * 
 * import sys as _sys
 * import itertools             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_itertools, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_itertools, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "pysamstats/opt.pyx":21
 * 
 * # PY2/3 compatibility
 * PY2 = _sys.version_info[0] == 2             # <<<<<<<<<<<<<<
 * if PY2:
 *     # noinspection PyUnresolvedReferences
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_2, 2, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __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_PY2, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":22
 * # PY2/3 compatibility
 * PY2 = _sys.version_info[0] == 2
 * if PY2:             # <<<<<<<<<<<<<<
 *     # noinspection PyUnresolvedReferences
 *     _string_types = basestring,
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PY2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "pysamstats/opt.pyx":24
 * if PY2:
 *     # noinspection PyUnresolvedReferences
 *     _string_types = basestring,             # <<<<<<<<<<<<<<
 * else:
 *     _string_types = str,
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)(&PyBaseString_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyBaseString_Type)));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyBaseString_Type)));
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_string_types, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "pysamstats/opt.pyx":22
 * # PY2/3 compatibility
 * PY2 = _sys.version_info[0] == 2
 * if PY2:             # <<<<<<<<<<<<<<
 *     # noinspection PyUnresolvedReferences
 *     _string_types = basestring,
 */
    goto __pyx_L2;
  }

  /* "pysamstats/opt.pyx":26
 *     _string_types = basestring,
 * else:
 *     _string_types = str,             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)(&PyString_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyString_Type)));
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_string_types, __pyx_t_2) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L2:;

  /* "pysamstats/opt.pyx":69
 * DEF BAM_CDIFF      = 8
 * 
 * cdef char* CODE2CIGAR= "MIDNSHP=X"             # <<<<<<<<<<<<<<
 * 
 * cdef char* bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"
 */
  __pyx_v_10pysamstats_3opt_CODE2CIGAR = ((char *)"MIDNSHP=X");

  /* "pysamstats/opt.pyx":71
 * cdef char* CODE2CIGAR= "MIDNSHP=X"
 * 
 * cdef char* bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_10pysamstats_3opt_bam_nt16_rev_table = ((char *)"=ACMGRSVTWYHKDBN");

  /* "pysamstats/opt.pyx":1826
 * 
 * 
 * def iter_pileup(stat, alignmentfile, fafile, pad, **kwargs):             # <<<<<<<<<<<<<<
 *     """General purpose function to generate statistics, where one record is
 *     generated for each genome position in the selected range, based on a
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_1iter_pileup, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_iter_pileup, __pyx_t_2) < 0) __PYX_ERR(0, 1826, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1845
 * 
 * 
 * def iter_pileup_default(stat, alignmentfile, fafile, chrom, start, end, one_based, truncate,             # <<<<<<<<<<<<<<
 *                         max_depth, int min_mapq, int min_baseq, bint no_del, bint no_dup):
 *     cdef:
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_3iter_pileup_default, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1845, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_iter_pileup_default, __pyx_t_2) < 0) __PYX_ERR(0, 1845, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1865
 * 
 * 
 * def stat_pileup(PileupStat stat,             # <<<<<<<<<<<<<<
 *                 PileupColumn col,
 *                 AlignmentFile alignmentfile,
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_6stat_pileup, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1865, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_stat_pileup, __pyx_t_2) < 0) __PYX_ERR(0, 1865, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1921
 * 
 * 
 * def iter_pileup_padded(stat, alignmentfile, fafile, chrom, **kwargs):             # <<<<<<<<<<<<<<
 *     if chrom is not None:
 *         it = iter_pileup_padded_chrom(stat, alignmentfile=alignmentfile, fafile=fafile,
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_8iter_pileup_padded, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1921, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_iter_pileup_padded, __pyx_t_2) < 0) __PYX_ERR(0, 1921, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1935
 * 
 * 
 * def iter_pileup_padded_chrom(PileupStat stat, alignmentfile, fafile, chrom, start, end,             # <<<<<<<<<<<<<<
 *                              one_based, truncate, max_depth, min_mapq, min_baseq, no_del, no_dup):
 *     cdef:
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_10iter_pileup_padded_chrom, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1935, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_iter_pileup_padded_chrom, __pyx_t_2) < 0) __PYX_ERR(0, 1935, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1986
 * 
 * 
 * def get_refbase(fafile, chrom, pos):             # <<<<<<<<<<<<<<
 *     if fafile is not None:
 *         refbase = fafile.fetch(reference=chrom, start=pos, end=pos+1).upper()
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_13get_refbase, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1986, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_refbase, __pyx_t_2) < 0) __PYX_ERR(0, 1986, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1996
 * 
 * 
 * def iter_binned(stat, alignmentfile, fafile, chrom, window_size=300, window_offset=None,             # <<<<<<<<<<<<<<
 *                 **kwargs):
 * 
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_15iter_binned, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_iter_binned, __pyx_t_2) < 0) __PYX_ERR(0, 1996, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":2025
 * 
 * 
 * def iter_binned_chrom(BinnedStat stat, AlignmentFile alignmentfile, FastaFile fafile,             # <<<<<<<<<<<<<<
 *                       chrom, start, end, one_based, int window_size, int window_offset,
 *                       int min_mapq, int no_dup):
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_17iter_binned_chrom, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2025, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_iter_binned_chrom, __pyx_t_2) < 0) __PYX_ERR(0, 2025, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":2104
 * 
 * 
 * def normalise_coords(AlignmentFile alignmentfile, chrom, start, end, one_based):             # <<<<<<<<<<<<<<
 *     """Convert to zero-based coordinates and deal with unspecified start
 *     and/or end.
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_20normalise_coords, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_normalise_coords, __pyx_t_2) < 0) __PYX_ERR(0, 2104, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":2158
 * 
 * 
 * def rootmean(uint64_t sqsum, int count):             # <<<<<<<<<<<<<<
 *     if count > 0:
 *         return int(round(sqrt(sqsum / count)))
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_22rootmean, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_rootmean, __pyx_t_2) < 0) __PYX_ERR(0, 2158, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":2165
 * 
 * 
 * def mean(int64_t total, int count):             # <<<<<<<<<<<<<<
 *     if count > 0:
 *         return int(round(total / count))
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_24mean, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_mean, __pyx_t_2) < 0) __PYX_ERR(0, 2165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":2175
 * 
 * 
 * def count_reads(AlignmentFile alignmentfile, chrom=None, start=None, end=None):             # <<<<<<<<<<<<<<
 *     cdef IteratorRowRegion it
 *     cdef int n = 0
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_10pysamstats_3opt_26count_reads, NULL, __pyx_n_s_pysamstats_opt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_count_reads, __pyx_t_2) < 0) __PYX_ERR(0, 2175, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "pysamstats/opt.pyx":1
 * # cython: profile=False             # <<<<<<<<<<<<<<
 * # cython: embedsignature=True
 * from __future__ import print_function, division, absolute_import
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

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

  /*--- 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 pysamstats.opt", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init pysamstats.opt");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#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

/* GetBuiltinName */
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;
}

/* RaiseArgTupleInvalid */
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);
}

/* KeywordStringCheck */
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;
}

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
}
#endif  // CYTHON_FAST_PYCCALL

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
#include "frameobject.h"
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = PyThreadState_GET();
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = f->f_localsplus;
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif  // CPython < 3.6
#endif  // CYTHON_FAST_PYCALL

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

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

/* PyObjectCallOneArg */
#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) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
#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);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyObjectCallNoArg */
  #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#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

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

/* PyErrFetchRestore */
    #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    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);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* WriteUnraisableException */
    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;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __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
}

/* GetModuleGlobalName */
    static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
    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;
}

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

/* ParseKeywords */
      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;
}

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_FloorDivideObjC(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);
            if (unlikely(b == -1 && ((unsigned long)a) == 0-(unsigned long)a))
                return PyInt_Type.tp_as_number->nb_floor_divide(op1, op2);
            else {
                long q, r;
                q = a / b;
                r = a - q*b;
                q -= ((r != 0) & ((r ^ b) < 0));
                x = q;
            }
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                default: return PyLong_Type.tp_as_number->nb_floor_divide(op1, op2);
            }
        }
                {
                    long q, r;
                    q = a / b;
                    r = a - q*b;
                    q -= ((r != 0) & ((r ^ b) < 0));
                    x = q;
                }
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                {
                    PY_LONG_LONG q, r;
                    q = lla / llb;
                    r = lla - q*llb;
                    q -= ((r != 0) & ((r ^ llb) < 0));
                    llx = q;
                }
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceFloorDivide : PyNumber_FloorDivide)(op1, op2);
}
#endif

/* IterFinish */
      static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    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
}

/* PyObjectCallMethod0 */
      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_UNPACK_METHODS
    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;
}

/* RaiseNeedMoreValuesToUnpack */
      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");
}

/* RaiseTooManyValuesToUnpack */
      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);
}

/* UnpackItemEndCheck */
      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;
}

/* RaiseNoneIterError */
      static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* UnpackTupleError */
      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);
    }
}

/* UnpackTuple2 */
      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;
}

/* dict_iter */
      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;
}

/* MergeKeywords */
      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;
}

/* ExtTypeTest */
      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;
}

/* ArgTypeTest */
      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;
}

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
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
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #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

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_TrueDivideObjC(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 a = PyInt_AS_LONG(op1);
            if (8 * sizeof(long) <= 53 || likely(labs(a) <= (1L << 53))) {
                return PyFloat_FromDouble((double)a / (double)b);
            }
            return PyInt_Type.tp_as_number->nb_true_divide(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        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 && 1 * PyLong_SHIFT < 53) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
                        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;
                    }
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
                        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;
                    }
                default: return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
            }
        }
                if ((8 * sizeof(long) <= 53 || likely(labs(a) <= (1L << 53)))
                    || __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) {
                    return PyFloat_FromDouble((double)a / (double)b);
                }
                return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
            return PyLong_FromLong(x);
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("divide", return NULL)
            result = ((double)a) / (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
}
#endif

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
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
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                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;
#ifdef HAVE_LONG_LONG
                    } 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;
#endif
                    }
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #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

/* None */
      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;
}

/* None */
      static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
    long r = a % b;
    r += ((r != 0) & ((r ^ b) < 0)) * b;
    return r;
}

/* CallNextTpTraverse */
      static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_traverse != current_tp_traverse)
        type = type->tp_base;
    while (type && type->tp_traverse == current_tp_traverse)
        type = type->tp_base;
    if (type && type->tp_traverse)
        return type->tp_traverse(obj, v, a);
    return 0;
}

/* CallNextTpClear */
      static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
    PyTypeObject* type = Py_TYPE(obj);
    while (type && type->tp_clear != current_tp_clear)
        type = type->tp_base;
    while (type && type->tp_clear == current_tp_clear)
        type = type->tp_base;
    if (type && type->tp_clear)
        type->tp_clear(obj);
}

/* SetVTable */
      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;
}

/* GetVTable */
      static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* Import */
      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;
}

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) {
            Py_RETURN_TRUE;
        } else {
            Py_RETURN_FALSE;
        }
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a;
        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;
                    }
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                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;
                    }
                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;
                    }
                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;
                    }
                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;
                    }
                #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15
                default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ);
                #else
                default: Py_RETURN_FALSE;
                #endif
            }
        }
            if (a == b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            if ((double)a == (double)b) {
                Py_RETURN_TRUE;
            } else {
                Py_RETURN_FALSE;
            }
    }
    return PyObject_RichCompare(op1, op2, Py_EQ);
}
#endif

/* GetItemInt */
      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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    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))
                        return NULL;
                    PyErr_Clear();
                }
            }
            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));
}

/* CodeObjectCache */
      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);
}

/* AddTraceback */
      #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;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntToPy */
      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);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPyVerify */
      #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;\
    }

/* CIntToPy */
      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);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* None */
      static CYTHON_INLINE int64_t __Pyx_pow_int64_t(int64_t b, int64_t e) {
    int64_t t = b;
    switch (e) {
        case 3:
            t *= b;
        case 2:
            t *= b;
        case 1:
            return t;
        case 0:
            return 1;
    }
    #if 1
    if (unlikely(e<0)) return 0;
    #endif
    t = 1;
    while (likely(e)) {
        t *= (b * (e&1)) | ((~e)&1);
        b *= b;
        e >>= 1;
    }
    return t;
}

/* CIntToPy */
      static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int64_t(int64_t value) {
    const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int64_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int64_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int64_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int64_t),
                                     little, !is_unsigned);
    }
}

/* None */
      static CYTHON_INLINE uint64_t __Pyx_pow_uint64_t(uint64_t b, uint64_t e) {
    uint64_t t = b;
    switch (e) {
        case 3:
            t *= b;
        case 2:
            t *= b;
        case 1:
            return t;
        case 0:
            return 1;
    }
    #if 0
    if (unlikely(e<0)) return 0;
    #endif
    t = 1;
    while (likely(e)) {
        t *= (b * (e&1)) | ((~e)&1);
        b *= b;
        e >>= 1;
    }
    return t;
}

/* CIntToPy */
      static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint64_t(uint64_t value) {
    const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint64_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint64_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint64_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(uint64_t),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
      static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint32_t(uint32_t value) {
    const uint32_t neg_one = (uint32_t) -1, const_zero = (uint32_t) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(uint32_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(uint32_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint32_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(uint32_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(uint32_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
      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))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } 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) (-(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))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#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_IntOrLong(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_IntOrLong(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;
}

/* CIntFromPy */
      static CYTHON_INLINE uint64_t __Pyx_PyInt_As_uint64_t(PyObject *x) {
    const uint64_t neg_one = (uint64_t) -1, const_zero = (uint64_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(uint64_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(uint64_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (uint64_t) 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 (uint64_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(uint64_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) >= 2 * PyLong_SHIFT) {
                            return (uint64_t) (((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) >= 3 * PyLong_SHIFT) {
                            return (uint64_t) (((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, 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(uint64_t) >= 4 * PyLong_SHIFT) {
                            return (uint64_t) (((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)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 (uint64_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(uint64_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint64_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (uint64_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(uint64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(uint64_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(uint64_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(uint64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (uint64_t) ((((((uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(uint64_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(uint64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (uint64_t) ((((((((uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(uint64_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, 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(uint64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint64_t) (((uint64_t)-1)*(((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(uint64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(uint64_t, 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(uint64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (uint64_t) ((((((((((uint64_t)digits[3]) << PyLong_SHIFT) | (uint64_t)digits[2]) << PyLong_SHIFT) | (uint64_t)digits[1]) << PyLong_SHIFT) | (uint64_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(uint64_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(uint64_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(uint64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            uint64_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(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 (uint64_t) -1;
        }
    } else {
        uint64_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (uint64_t) -1;
        val = __Pyx_PyInt_As_uint64_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to uint64_t");
    return (uint64_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to uint64_t");
    return (uint64_t) -1;
}

/* CIntFromPy */
      static CYTHON_INLINE int64_t __Pyx_PyInt_As_int64_t(PyObject *x) {
    const int64_t neg_one = (int64_t) -1, const_zero = (int64_t) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int64_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int64_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int64_t) 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 (int64_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int64_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 2 * PyLong_SHIFT) {
                            return (int64_t) (((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) >= 3 * PyLong_SHIFT) {
                            return (int64_t) (((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, 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(int64_t) >= 4 * PyLong_SHIFT) {
                            return (int64_t) (((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)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 (int64_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int64_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int64_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int64_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int64_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int64_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int64_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int64_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                            return (int64_t) ((((((int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int64_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int64_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                            return (int64_t) ((((((((int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int64_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, 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(int64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int64_t) (((int64_t)-1)*(((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int64_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int64_t, 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(int64_t) - 1 > 4 * PyLong_SHIFT) {
                            return (int64_t) ((((((((((int64_t)digits[3]) << PyLong_SHIFT) | (int64_t)digits[2]) << PyLong_SHIFT) | (int64_t)digits[1]) << PyLong_SHIFT) | (int64_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int64_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int64_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int64_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int64_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(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 (int64_t) -1;
        }
    } else {
        int64_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int64_t) -1;
        val = __Pyx_PyInt_As_int64_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int64_t");
    return (int64_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int64_t");
    return (int64_t) -1;
}

/* CIntFromPy */
      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))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } 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) (-(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))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#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_IntOrLong(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_IntOrLong(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;
}

/* FetchCommonType */
      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;
}

/* RaiseException */
      #if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    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_PyThreadState_assign
    __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

/* SwapException */
        #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    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;
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* PyObjectCallMethod1 */
        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 done;
#if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *args;
            PyObject *function = PyMethod_GET_FUNCTION(method);
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(function)) {
                PyObject *args[2] = {self, arg};
                result = __Pyx_PyFunction_FastCall(function, args, 2);
                goto done;
            }
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(function)) {
                PyObject *args[2] = {self, arg};
                result = __Pyx_PyCFunction_FastCall(function, args, 2);
                goto done;
            }
            #endif
            args = PyTuple_New(2);
            if (unlikely(!args)) goto done;
            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);
done:
    Py_XDECREF(method);
    return result;
}

/* CoroutineBase */
        #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_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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 (!ev) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#if PY_VERSION_HEX >= 0x030300A0
        else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
        }
#endif
        else if (unlikely(PyTuple_Check(ev))) {
            if (PyTuple_GET_SIZE(ev) >= 1) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                value = PyTuple_GET_ITEM(ev, 0);
                Py_INCREF(value);
#else
                value = PySequence_ITEM(ev, 0);
#endif
            } else {
                Py_INCREF(Py_None);
                value = Py_None;
            }
            Py_DECREF(ev);
        }
        else if (!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            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;
    __Pyx_PyThreadState_declare
    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;
    }
    __Pyx_PyThreadState_assign
    if (value) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        if (self->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(__pyx_tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = __pyx_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 || CYTHON_COMPILING_IN_PYSTON
#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 = Py_TYPE(yf)->tp_iternext(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;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
            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;
    __Pyx_PyThreadState_declare
    if (gen->resume_label <= 0)
        return ;
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_PyThreadState_assign
    __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)
{
    PyObject *name = self->gi_name;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return 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)
{
    PyObject *name = self->gi_qualname;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
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, PyObject *module_name) {
    __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;
    Py_XINCREF(module_name);
    gen->gi_modulename = module_name;
    PyObject_GC_Track(gen);
    return gen;
}

/* PatchModuleWithCoroutine */
            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;
}

/* PatchGeneratorABC */
            #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;
}

/* Generator */
            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;
}

/* CheckBinaryVersion */
            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;
}

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

/* TypeImport */
            #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. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        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. Expected %zd, got %zd",
            module_name, class_name, basicsize, size);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

/* InitStrings */
            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_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  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);
#if CYTHON_USE_TYPE_SLOTS
  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
#else
  res = PyNumber_Int(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 */
